-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
966e8c3
commit bb3fa7f
Showing
6 changed files
with
187 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Service with ingress nginx | ||
|
||
1. Install ingress nginx controller | ||
|
||
[Install ingress](/k8s/setup/minikube/install_ingress.md) | ||
|
||
2. Verify installation | ||
|
||
``` | ||
kubectl get pods --all-namespaces -l app.kubernetes.io/name=ingress-nginx | ||
``` | ||
|
||
3. Apply k8s configuration | ||
|
||
note: assume you are at root of repository | ||
|
||
``` | ||
kubectl apply -f ./ | ||
``` | ||
|
||
4. Check exposed ip of ingress | ||
|
||
notes: will take litle time to assign IP address | ||
|
||
``` | ||
kubectl get ingress http-app-ingress | ||
``` | ||
|
||
Output example: | ||
|
||
``` | ||
Output: | ||
NAME HOSTS ADDRESS PORTS AGE | ||
http-app-ingress * 192.168.99.101 80 8m18s | ||
``` | ||
|
||
``` | ||
Internet IP | ||
| | ||
[ Ingress ] | ||
--|-----|-- | ||
[ Services ] | ||
``` | ||
|
||
5. Try try try | ||
|
||
``` | ||
curl -v 192.168.99.101:80/sub-path/ | ||
``` | ||
|
||
Output: | ||
``` | ||
* Trying 192.168.99.101... | ||
* TCP_NODELAY set | ||
* Connected to 192.168.99.101 (192.168.99.101) port 80 (#0) | ||
> GET /sub-path/ HTTP/1.1 | ||
> Host: 192.168.99.101 | ||
> User-Agent: curl/7.64.1 | ||
> Accept: */* | ||
> | ||
< HTTP/1.1 200 OK | ||
< Server: openresty/1.15.8.2 | ||
< Date: Thu, 23 Jan 2020 20:01:08 GMT | ||
< Content-Type: text/plain; charset=utf-8 | ||
< Content-Length: 12 | ||
< Connection: keep-alive | ||
< X-App-Name: http-echo | ||
< X-App-Version: 0.2.3 | ||
< | ||
Hello world | ||
* Connection #0 to host 192.168.99.101 left intact | ||
* Closing connection 0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ingress-nginx-relative-path-app1 | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: ingress-nginx-relative-path-app1 | ||
template: | ||
metadata: | ||
labels: | ||
app: ingress-nginx-relative-path-app1 | ||
spec: | ||
containers: | ||
- | ||
env: | ||
- name: CUSTOM_ROUTES | ||
value: "/css/style.css:this is css;/random.8b3ec8ff2ac96774ff4e6965e9bba307.html:this is random;/:this is index file of app1" | ||
image: "ledongthuc/hello-api:latest" | ||
name: ingress-nginx-relative-path-app1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ingress-nginx-relative-path-app2 | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: ingress-nginx-relative-path-app2 | ||
template: | ||
metadata: | ||
labels: | ||
app: ingress-nginx-relative-path-app2 | ||
spec: | ||
containers: | ||
- | ||
env: | ||
- name: CUSTOM_ROUTES | ||
value: "/api/xyz:this is api;/this is index file of app2" | ||
image: "ledongthuc/hello-api:latest" | ||
name: ingress-nginx-relative-path-app2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: ingress-nginx-relative-path-app1 | ||
annotations: | ||
kubernetes.io/ingress.class: "nginx" # ingress will scan it | ||
spec: | ||
rules: | ||
- http: | ||
paths: | ||
- path: /css/ | ||
backend: | ||
serviceName: ingress-nginx-relative-path-app1 | ||
servicePort: 8080 | ||
- path: /random* | ||
backend: | ||
serviceName: ingress-nginx-relative-path-app1 | ||
servicePort: 8080 | ||
- path: / | ||
backend: | ||
serviceName: ingress-nginx-relative-path-app1 | ||
servicePort: 8080 | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: ingress-nginx-relative-path-app2 | ||
annotations: | ||
kubernetes.io/ingress.class: "nginx" # ingress will scan it | ||
spec: | ||
rules: | ||
- http: | ||
paths: | ||
- path: /api/ | ||
backend: | ||
serviceName: ingress-nginx-relative-path-app2 | ||
servicePort: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ingress-nginx-relative-path-app1 | ||
spec: | ||
ports: | ||
- port: 8080 | ||
selector: | ||
app: ingress-nginx-relative-path-app1 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ingress-nginx-relative-path-app2 | ||
spec: | ||
ports: | ||
- port: 8080 | ||
selector: | ||
app: ingress-nginx-relative-path-app2 |