better readability
This commit is contained in:
parent
396e4dd196
commit
07febe44c0
93
README.md
93
README.md
@ -48,69 +48,76 @@ Example Workflow: Create a new cluster and use it with `kubectl`
|
||||
|
||||
### Expose services
|
||||
|
||||
#### via Ingress
|
||||
#### 1. via Ingress
|
||||
|
||||
1. Create a cluster, mapping the ingress port 80 to localhost:8081
|
||||
`k3d create --api-port 6550 --publish 8081:80 --workers 2`
|
||||
|
||||
`k3d create --api-port 6550 --publish 8081:80 --workers 2`
|
||||
|
||||
2. Get the kubeconfig file
|
||||
`export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"`
|
||||
|
||||
`export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"`
|
||||
|
||||
3. Create a nginx deployment
|
||||
`kubectl create deployment nginx --image=nginx`
|
||||
|
||||
`kubectl create deployment nginx --image=nginx`
|
||||
|
||||
4. Create a ClusterIP service for it
|
||||
`kubectl create service clusterip nginx --tcp=80:80`
|
||||
|
||||
`kubectl create service clusterip nginx --tcp=80:80`
|
||||
|
||||
5. Create an ingress object for it with `kubectl apply -f`
|
||||
|
||||
```YAML
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: nginx
|
||||
annotations:
|
||||
ingress.kubernetes.io/ssl-redirect: "false"
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
backend:
|
||||
serviceName: nginx
|
||||
servicePort: 80
|
||||
```
|
||||
```YAML
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: nginx
|
||||
annotations:
|
||||
ingress.kubernetes.io/ssl-redirect: "false"
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
backend:
|
||||
serviceName: nginx
|
||||
servicePort: 80
|
||||
```
|
||||
|
||||
6. Curl it via localhost
|
||||
`curl localhost:8081/`
|
||||
|
||||
### via NodePort
|
||||
`curl localhost:8081/`
|
||||
|
||||
#### 2. via NodePort
|
||||
|
||||
1. Create a cluster, mapping the port 30080 from worker-0 to localhost:8082
|
||||
`k3d create --publish 8082:30080@k3d-k3s-default-worker-0 --workers 2 -a 6550`
|
||||
|
||||
`k3d create --publish 8082:30080@k3d-k3s-default-worker-0 --workers 2 -a 6550`
|
||||
|
||||
... (Steps 2 and 3 like above) ...
|
||||
|
||||
4. Create a NodePort service for it with `kubectl apply -f`
|
||||
|
||||
```YAML
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
ports:
|
||||
- name: 80-80
|
||||
nodePort: 30080
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: nginx
|
||||
type: NodePort
|
||||
```
|
||||
```YAML
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
ports:
|
||||
- name: 80-80
|
||||
nodePort: 30080
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: nginx
|
||||
type: NodePort
|
||||
```
|
||||
|
||||
5. Curl it via localhost
|
||||
`curl localhost:8082/`
|
||||
|
||||
`curl localhost:8082/`
|
||||
|
Loading…
Reference in New Issue
Block a user