From dd42d6748aec09ee8bc5f401f29b6495a07e3778 Mon Sep 17 00:00:00 2001 From: albert_q Date: Tue, 13 Jul 2021 14:45:59 +0200 Subject: [PATCH] use kustomize instead of kubectl edit --- README-KIND.md | 65 +++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/README-KIND.md b/README-KIND.md index 413af4b..c126ff7 100644 --- a/README-KIND.md +++ b/README-KIND.md @@ -142,7 +142,7 @@ root@my-cluster-control-plane:/# systemctl status kubelet.service ... ``` -> Note: +> Note: > 1. Frankly, after `docker exec` into the "node", you really can't differentiate whether you're in a real VM or a Docker container -- the components are exactly the same as what I have provisioned by using `kubeadm` on VMs; > 2. You may check out [this repo](https://github.com/brightzheng100/kubernetes-the-kubeadm-way) to see how to provision a **real and fully-fledged** `kubeadm`-based cluster on GCP. @@ -227,37 +227,38 @@ As we've explored the way how to use `NodePort` to expose services to the extern So let's take `traefik` as an example: -``` -$ kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-rbac.yaml -$ kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-ds.yaml -$ kubectl edit service/traefik-ingress-service -n kube-system -``` - -Make sure we update `traefik`'s service, like this: - -```sh -$ kubectl apply -n kube-system -f - < kustomization.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +bases: + - https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-rbac.yaml + - https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-ds.yaml + +patchesStrategicMerge: + - |- + apiVersion: v1 + kind: Service + metadata: + name: traefik-ingress-service + namespace: kube-system + spec: + type: NodePort + selector: + k8s-app: traefik-ingress-lb + ports: + - protocol: TCP + port: 80 + nodePort: 30100 # <-- 2. add this nodePort binding to one of the node ports exposed + name: web + - protocol: TCP + port: 8080 + nodePort: 30101 # <-- 3. add this nodePort binding to another one of the node ports exposed + name: admin EOF +$ kubectl apply -k . ``` - Test it out: ```sh @@ -409,7 +410,7 @@ $ docker run -d --restart always \ --network kind \ alpine/socat -dd \ tcp-listen:${SVC_PORT},fork,reuseaddr tcp-connect:target:${SVC_PORT} - + # Now we can access it directly $ curl -s http://127.0.0.1:$SVC_PORT | grep title Welcome to nginx! @@ -489,7 +490,7 @@ Then you will have a `kind`-powered Kubernetes cluster, with: - 3 x Worker Node - 1 x local Docker Registry, which is accessible from Kubernetes cluster, with prefix of `registry:5000/`. For example, `registry:5000/busybox` -> Notes: +> Notes: 1. You may customize the cluster creation script by exporting below variables to replace the default: - KIND_CLUSTER_NAME, defaults to "my-cluster" - KIND_CLUSTER_VERSION, defaults to "kindest/node:latest"