From 07febe44c07d4bf2c2f0a161aedf8f8dad9adece Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Wed, 15 May 2019 08:40:48 +0200 Subject: [PATCH] better readability --- README.md | 93 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index d4a8b596..467a9475 100644 --- a/README.md +++ b/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/`