当前位置:网站首页>Using k3s to create local development cluster

Using k3s to create local development cluster

2020-11-08 16:10:00 InfoQ

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/a1/a1f85e11678c1fe86abf0542ab6465b0.png","alt":"Treafik Logo","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Reference documents :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://mp.weixin.qq.com/s?__biz=MzU4MjQ0MTU4Ng==&mid=2247486685&idx=1&sn=e84b383bb73f75d8059bcceeb8413a6a&chksm=fdb903c0cace8ad6bff3cd0aeee1738c5d27db0e9fc20a6b6c00b81da39a033a2ded9c8dfd87","title":null},"content":[{"type":"text","text":"k8s Technology circle - Yangming - Use K3s and Traefik Create a local development cluster "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" Local cluster requirements "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":null,"normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":" Light weight ; ( The download package is small )"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":" Fast start ; ( It is best to docker Mode start , Instead of VM)"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","text":" Less occupied resources ; ( It is best to docker Mode start , Instead of VM. And need to be a possession of Kubernetes Fully functional , A streamlined distribution )"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Used to minikube, VM Startup is slow , And when you download the latest version , Ali cloud, mirror There's no latest version of the mirror , It can't start up all the time . Very afflictive ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" be based on K3S Of K3D Perfect for the above needs of me ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"K3S brief introduction - Lightweight Kubernetes"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Reference documents :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://docs.rancher.cn/docs/k3s/_index","title":null},"content":[{"type":"text","text":"rancher.cn - K3s - Lightweight Kubernetes"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Lightweight Kubernetes. Simple installation , Only half of memory , None of the binary is 200MB. contain K3S The full mirror size for is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":""},"content":[{"type":"text","text":" REPOSITORY                       TAG                 IMAGE ID           CREATED             SIZE\n rancher/k3s                     v1.18.2-k3s1       e9f6bccce7de       6 months ago       151MB"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" After I have finished the installation here , ( Installed again traefik and Kubernetes dashboard And a demo deployment), The consumption is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"CPU: 0.3 Core"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":" Memory : 1.2 G"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/81/81f4977892503cd85810560f65f606c5.png","alt":"image-20201107213926142","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Apply to :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Edge of computing -Edge"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The Internet of things -IoT"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"CI"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Development"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ARM"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The embedded K8s"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Don't want to get deep in k8s Operation and maintenance management personnel "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"K3s It's a complete fit Kubernetes Distribution version , There are the following enhancements ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Packaging for "},{"type":"text","marks":[{"type":"strong"}],"text":" Single binary "},{"type":"text","text":" file ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" be based on "},{"type":"text","marks":[{"type":"strong"}],"text":"sqlite3"},{"type":"text","text":" As the default storage mechanism . etcd3,MySQL,Postgres Still available ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Packaged in a simple startup program , This startup program handles a lot of complicated TLS And options ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" By default, it's safe , There are reasonable defaults for lightweight environments ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Added simple but powerful “batteries-included” function , for example : Local storage provider , Service load balancer ,"},{"type":"text","marks":[{"type":"strong"}],"text":"Helm"},{"type":"text","text":" controller and "},{"type":"text","marks":[{"type":"strong"}],"text":"Traefik"},{"type":"text","text":" ingress controller."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" all Kubernetes The operations of the control plane components are encapsulated in a single binary file and process . This makes K3s Can automate and manage complex cluster operations , For example, distribute certificates ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" External dependencies are minimized ( Just need the modern kernel and cgroup mount ). K3s The package needs dependencies , Include :"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"K3D - K3S in docker"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"k3d Create container k3s colony . It means , You can use docker Starting multiple nodes on a single computer k3s colony ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"K3D Quick start "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Reference documents :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://docs.rancher.cn/docs/octopus/quick-start/_index#1-%E4%BD%BF%E7%94%A8k3d%E6%90%AD%E5%BB%BAk3s%E9%9B%86%E7%BE%A4%E5%8F%AF%E9%80%89","title":null},"content":[{"type":"text","text":"rancher.cn - Use k3d build k3s colony "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Use k3d build k3s colony . "},{"type":"link","attrs":{"href":"https://github.com/rancher/k3d","title":null},"content":[{"type":"text","text":"k3d"}]},{"type":"text","text":" It is to build containers quickly k3s Clustering tools . have access to Docker Starting multiple nodes on a single computer k3s colony ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" remarks :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" My computer environment :"}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"win10 pro 2004"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"WSL2 + Ubuntu20.04 + docker desktop"}]}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":null,"normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":" Run the following command , Start up has 3 individual worker Node local k3s colony .( Build a cluster and spit up , There are official scripts ready to use directly . It is good to test domestic use ) Use "},{"type":"codeinline","content":[{"type":"text","text":"root"}]},{"type":"text","text":" perform :"}]}]}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"curl -fL https://octopus-assets.oss-cn-beijing.aliyuncs.com/k3d/cluster-k3s-spinup.sh | bash -"}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"️ Be careful :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" If the installation is successful , You should see the following log :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"codeinline","content":[{"type":"text","text":"please input CTRL+C to stop the local cluster"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" If you want to stop K3S colony , Please run "},{"type":"codeinline","content":[{"type":"text","text":"CTRL+C"}]}]}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":" % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n100 13549 100 13549 0 0 6784 0 0:00:01 0:00:01 --:--:-- 6781\n[INFO] [1107 17:02:03] cleanup proxy config\n[INFO] [1107 17:02:03] creating edge cluster with v1.18.2\n[INFO] [1107 17:02:03] INGRESS_HTTP_PORT is 54836\n[INFO] [1107 17:02:03] INGRESS_HTTPS_PORT is 54837\nINFO[0000] Created cluster network with ID ba03de48d65b8e1fbef6ff03cbba0b9e9ad008e7cc81d67d8393c69272a1c4b9\nINFO[0000] Add TLS SAN for 0.0.0.0\nINFO[0000] Created docker volume k3d-edge-images\nINFO[0000] Creating cluster [edge]\nINFO[0000] Creating server using docker.io/rancher/k3s:v1.18.2-k3s1...\nINFO[0006] SUCCESS: created cluster [edge]\nINFO[0006] You can now use the cluster with:\n\nexport KUBECONFIG=\"$(k3d get-kubeconfig --name='edge')\"\nkubectl cluster-info\n[WARN] [1107 17:02:09] default kubeconfig has been backup in /root/.kube/config_k3d_bak\n[INFO] [1107 17:02:09] edge cluster's kubeconfig wrote in /root/.kube/config now\n[INFO] [1107 17:02:09] waiting node edge-control-plane for ready\nINFO[0000] Adding 1 agent-nodes to k3d cluster edge...\nINFO[0000] Created agent-node with ID 752aebb8f9bb1af1c5fcf62ff9313163c243835373872595f38de03004257514\n[INFO] [1107 17:02:21] waiting node edge-worker for ready\nINFO[0000] Adding 1 agent-nodes to k3d cluster edge...\nINFO[0000] Created agent-node with ID 7d0aa70e24f387217d3094911a7c0f5fa2f504c1fe3e106b08d00f3a6b11158c\n[INFO] [1107 17:02:34] waiting node edge-worker1 for ready\nINFO[0000] Adding 1 agent-nodes to k3d cluster edge...\nINFO[0000] Created agent-node with ID 7b880c8966f9b8b252c5385ee10167384d9517c87ff60763989b69f5c3f344ab\n[INFO] [1107 17:02:47] waiting node edge-worker2 for ready\n[WARN] [1107 17:02:59] please input CTRL+C to stop the local cluster"}]},{"type":"numberedlist","attrs":{"start":2,"normalizeStart":2},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":" Open a new terminal , And configuration "},{"type":"codeinline","content":[{"type":"text","text":"KUBECONFIG"}]},{"type":"text","text":" To access local k3s colony ."}]}]}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"export KUBECONFIG=\"$(k3d get-kubeconfig --name='edge')\"\nkubectl cluster-info"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The output is as follows :"}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"Kubernetes master is running at https://0.0.0.0:54835\nCoreDNS is running at https://0.0.0.0:54835/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy\nMetrics-server is running at https://0.0.0.0:54835/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy"}]},{"type":"numberedlist","attrs":{"start":3,"normalizeStart":3},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","text":" function "},{"type":"codeinline","content":[{"type":"text","text":"kubectl get node"}]},{"type":"text","text":" command , Check local k3s Whether the nodes of the cluster are normal :"}]}]}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# kubectl get node\nNAME STATUS ROLES AGE VERSION\nedge-worker Ready 3h17m v1.18.2+k3s1\nedge-worker2 Ready 3h17m v1.18.2+k3s1\nedge-control-plane Ready master 3h17m v1.18.2+k3s1\nedge-worker1 Ready 3h17m v1.18.2+k3s1"}]},{"type":"numberedlist","attrs":{"start":4,"normalizeStart":4},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":4,"align":null,"origin":null},"content":[{"type":"text","text":" function "},{"type":"codeinline","content":[{"type":"text","text":"kubectl get pod -A"}]},{"type":"text","text":" command , Check local k3s Clustered pod If there is something wrong : ( By default, it's deployed traefik)"}]}]}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"kubectl get pod -A\nNAMESPACE NAME READY STATUS RESTARTS AGE\nkube-system metrics-server-7566d596c8-6h776 1/1 Running 0 3h18m\nkube-system local-path-provisioner-6d59f47c7-sz5tp 1/1 Running 0 3h18m\nkube-system coredns-8655855d6-lmrkq 1/1 Running 0 3h18m\nkube-system svclb-traefik-wxp6k 2/2 Running 0 133m\nkube-system svclb-traefik-jls5w 2/2 Running 0 133m\nkube-system svclb-traefik-j776k 2/2 Running 0 133m\nkube-system svclb-traefik-qbfx4 2/2 Running 0 133m\nkube-system helm-install-traefik-jxptl 0/1 Completed 0 120m\nkube-system traefik-6cbfb44969-r9fj2 1/1 Running 0 118m"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" note :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"K3D The quick start script for , It involves the following docker Mirror image : ( Only the first image is outside pull Of , The other images are actually created after startup k3s In the container pull Of .)"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# docker images\nREPOSITORY TAG IMAGE ID CREATED SIZE\nrancher/k3s v1.18.2-k3s1 e9f6bccce7de 6 months ago 151MB\nrancher/klipper-helm v0.2.5 6207e2a3f522 6 months ago 136MB\nrancher/library-traefik 1.7.19-amd64 aa764f7db305 12 months ago 85.7MB\nrancher/metrics-server v0.3.6 9dd718864ce6 13 months ago 39.9MB\nrancher/local-path-provisioner v0.0.11 9d12f9848b99 13 months ago 36.2MB\nrancher/coredns-coredns 1.6.3 c4d3d16fe508 14 months ago 44.3MB"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"K3D The quick start script for , It will start 4 individual docker The container serves as 4 individual node node :"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"sudo docker ps\nCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n7b880c8966f9 rancher/k3s:v1.18.2-k3s1 \"/bin/k3s agent --no…\" 3 hours ago Up 3 hours k3d-edge-worker-3\n7d0aa70e24f3 rancher/k3s:v1.18.2-k3s1 \"/bin/k3s agent --no…\" 3 hours ago Up 3 hours k3d-edge-worker-2\n752aebb8f9bb rancher/k3s:v1.18.2-k3s1 \"/bin/k3s agent --no…\" 3 hours ago Up 3 hours k3d-edge-worker-1\ndca9851cf5d6 rancher/k3s:v1.18.2-k3s1 \"/bin/k3s server --h…\" 3 hours ago Up 3 hours 0.0.0.0:54835->54835/tcp, 0.0.0.0:54836->80/tcp, 0.0.0.0:54837->443/tcp k3d-edge-server"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" As you can see from the above , 1 individual k3s server( It's the control plane ), 3 individual k3s agent. k3s server Exposed to the outside world 3 individual "},{"type":"text","marks":[{"type":"strong"}],"text":" Random "},{"type":"text","text":" port :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":null,"normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"54835->54835"},{"type":"text","text":": K8S API"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"54836->80"},{"type":"text","text":": K8S Ingress Of HTTP port ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"54837->443"},{"type":"text","text":": K8S Ingress Of HTTPS port ."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":" Deploy Traefik Dashboard"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" So we need to access the application deployed in the container , Just use this 2 Random ports : "},{"type":"link","attrs":{"href":"http://localhost:54836","title":null},"content":[{"type":"text","text":"http://localhost:54836"}]},{"type":"text","text":" or "},{"type":"link","attrs":{"href":"https://localhost:54836","title":null},"content":[{"type":"text","text":"https://localhost:54836"}]},{"type":"text","text":" . When it's deployed , By default, there is nothing Ingress Of , So visit this 2 All addresses are newspapers : "},{"type":"codeinline","content":[{"type":"text","text":"404"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" And the default script is not enabled Traefik Of Dashboard Of , Inconvenient management . We'll enable it ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The first is to get into k3s server In the container . This container doesn't have "},{"type":"codeinline","content":[{"type":"text","text":"/bin/bash"}]},{"type":"text","text":", Only "},{"type":"codeinline","content":[{"type":"text","text":"/bin/sh"}]},{"type":"text","text":", as follows :"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# docker exec -it ls /bin\naddgroup cat containerd-shim df expr fstrim i2cdetect ipcs kubectl lsof mkswap openvt ptx runcon sha512sum swapoff tr unxz whoami\nadduser charon containerd-shim-runc-v2 diff factor fuser i2cdump iplink last lspci mktemp partprobe pwd runlevel shred swapon traceroute unzip xargs\nar chattr coreutils dir fallocate getopt i2cget ipneigh less lsscsi modprobe passwd rdate sed shuf switch_root true uptime xtables-legacy-multi\narch chcon cp dircolors false getty i2cset iproute link lsusb more paste readlink seq sleep sync truncate users xxd\narp check-config cpio dirname fbset ginstall id iprule linux32 lzcat mountpoint patch readprofile setarch slirp4netns sysctl tsort usleep xz\narping chgrp crictl dmesg fdflush grep ifconfig ipset linux64 lzma mt pathchk realpath setconsole socat syslogd tty uudecode xzcat\nash chmod crond dnsd fdformat groups ifdown iptables linuxrc lzopcat mv pidof reboot setfattr sort tac ubirename uuencode yes\naux chown crontab dnsdomainname fdisk gunzip ifup iptables-restore ln makedevs nameif pigz renice setkeycodes split tail udhcpc vconfig zcat\nawk chroot csplit dos2unix fgrep gzip inetd iptables-save loadfont md5sum netstat ping reset setlogcons start-stop-daemon tar uevent vdir\nb2sum chrt ctr du find halt init iptunnel loadkmap mdev nice pinky resize setpriv stat tc umount vi\nbase32 chvt cut dumpkmap flannel hdparm insmod join logger mesg nl pipe_progress resume setserial strings tee uname vlock\nbase64 cksum date ebtables flock head install k3s login microcom nohup pivot_root rm setsid stty telnet unexpand w\nbasename clear dc echo fmt hexdump ip k3s-agent logname mkdir nproc portmap rmdir sh su test uniq watch\nblkid cmp dd egrep fold hexedit ip6tables k3s-server loopback mkdosfs nsenter poweroff rmmod sha1sum sulogin tftp unix2dos watchdog\nbridge cni deallocvt eject free host-local ip6tables-restore kill losetup mke2fs nslookup pr route sha224sum sum time unlink wc\nbunzip2 comm delgroup env freeramdisk hostid ip6tables-save killall ls mkfifo nuke printenv run-init sha256sum svc timeout unlzma wget\nbusybox conntrack deluser ether-wake fsck hostname ipaddr killall5 lsattr mknod numfmt printf run-parts sha384sum svok top unlzop which\nbzcat containerd devmem expand fsfreeze hwclock ipcrm klogd lsmod mkpasswd od ps runc sha3sum swanctl touch unpigz who"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" So pass "},{"type":"codeinline","content":[{"type":"text","text":"/bin/sh"}]},{"type":"text","text":" Into the container :"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# docker exec -it /bin/sh\n--------------- It's in the container --------------\n/ # cd /var/lib/rancher/k3s/server/manifests\n/var/lib/rancher/k3s/server/manifests # vi traefik.yaml"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Edited "},{"type":"codeinline","content":[{"type":"text","text":"traefik.yaml"}]},{"type":"text","text":" as follows : ( increase :"},{"type":"codeinline","content":[{"type":"text","text":"dashboard.enabled: \"true\""}]},{"type":"text","text":" )"}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"apiVersion: helm.cattle.io/v1\nkind: HelmChart\nmetadata:\n name: traefik\n namespace: kube-system\nspec:\n chart: https://%{KUBERNETES_API}%/static/charts/traefik-1.81.0.tgz\n valuesContent: |-\n rbac:\n enabled: true\n ssl:\n enabled: true\n metrics:\n prometheus:\n enabled: true\n kubernetes:\n ingressEndpoint:\n useDefaultPublishedService: true\n dashboard:\n enabled: true\n image: \"rancher/library-traefik\"\n tolerations:\n - key: \"CriticalAddonsOnly\"\n operator: \"Exists\"\n - key: \"node-role.kubernetes.io/master\"\n operator: \"Exists\"\n effect: \"NoSchedule\""}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" After saving, it will be redeployed "},{"type":"codeinline","content":[{"type":"text","text":"traefik.yaml"}]},{"type":"text","text":", as follows :"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# kubectl get events -n kube-system\nLAST SEEN TYPE REASON OBJECT MESSAGE\n43s Normal Pulled pod/helm-install-traefik-jxptl Successfully pulled image \"rancher/klipper-helm:v0.2.5\"\n43s Normal Created pod/helm-install-traefik-jxptl Created container helm\n43s Normal Started pod/helm-install-traefik-jxptl Started container helm\n43s Normal ScalingReplicaSet deployment/traefik Scaled up replica set traefik-6cbfb44969 to 1\n43s Normal SuccessfulCreate replicaset/traefik-6cbfb44969 Created pod: traefik-6cbfb44969-r9fj2\n Normal Scheduled pod/traefik-6cbfb44969-r9fj2 Successfully assigned kube-system/traefik-6cbfb44969-r9fj2 to edge-worker2\n42s Normal Pulling pod/traefik-6cbfb44969-r9fj2 Pulling image \"rancher/library-traefik:1.7.19\"\n42s Normal Completed job/helm-install-traefik Job completed\n41s Normal SandboxChanged pod/helm-install-traefik-jxptl Pod sandbox changed, it will be killed and re-created.\n9s Normal Pulled pod/traefik-6cbfb44969-r9fj2 Successfully pulled image \"rancher/library-traefik:1.7.19\"\n9s Normal Created pod/traefik-6cbfb44969-r9fj2 Created container traefik\n9s Normal Started pod/traefik-6cbfb44969-r9fj2 Started container traefik"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" After deployment , It will be configured automatically ingress, as follows :"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# kubectl get ingress -A\nNAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE\nkube-system traefik-dashboard traefik.example.com 172.18.0.2 80 149m"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" So we configure hosts: "},{"type":"codeinline","content":[{"type":"text","text":"127.0.0.1 traefik.example.com"}]},{"type":"text","text":". You can access : "},{"type":"link","attrs":{"href":"http://traefik.example.com:54836/dashboard/","title":null},"content":[{"type":"text","text":"http://traefik.example.com:54836/dashboard/"}]},{"type":"text","text":", As shown in the figure below :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/c2/c2db0087062fba9b9e491ebc8ddf8d1a.png","alt":"image-20201107205521383","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" remarks :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" There is actually another way to access : "},{"type":"codeinline","content":[{"type":"text","text":"kubectl port-forward"}]},{"type":"text","text":". as follows :"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":" $ kubectl port-forward $(kubectl get pods --selector \"app=traefik\" --output=name -n kube-system) --address 0.0.0.0 8080:8080 -n kube-system"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" You can use the "},{"type":"link","attrs":{"href":"http://localhost:8080/dashboard/","title":null},"content":[{"type":"text","text":"http://localhost:8080/dashboard/"}]},{"type":"text","text":" Access to the traefik Management page ."}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" Deploy the application "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Use "},{"type":"codeinline","content":[{"type":"text","text":"whoami"}]},{"type":"text","text":" Application deployment test ."}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"$ kubectl create deploy whoami --image containous/whoami\ndeployment.apps/whoami created\n$ kubectl expose deploy whoami --port 80\nservice/whoami exposed"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Then we define a Ingress Rules to use our new Traefik,Traefik Can read your own CRD IngressRoute, It can also read traditional Ingress resources ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":" vi whoami-ingress.yaml"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The details are as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"apiVersion: networking.k8s.io/v1beta1\nkind: Ingress\nmetadata:\n name: whoami\n annotations:\n traefik.ingress.kubernetes.io/router.entrypoints: web,websecure\n traefik.ingress.kubernetes.io/router.tls: \"true\"\nspec:\n rules:\n - http:\n paths:\n - path: /\n backend:\n serviceName: whoami\n servicePort: 80"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"codeinline","content":[{"type":"text","text":"kubectl apply"}]},{"type":"text","text":" application :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":" kubectl apply -f whoami-ingress.yaml -n default"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" In this case , We are HTTP and HTTPs Two entry points are exposed whoami service , every last URL Will be sent to the service , We can do it in Traefik Dashboard I see a new Ingress."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/61/61a425550387c908d1d32d4609f00121.png","alt":"image-20201107210458283","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" To test the application, we can access it directly in the browser :"},{"type":"link","attrs":{"href":"http://localhost:54836/","title":null},"content":[{"type":"text","text":"http://localhost:54836/"}]},{"type":"text","text":" that will do , This is because we installed Traefik Automatically create a LoadBalancer Of Service service . Why add port number , because k3s server In a container , Mapping to the outside is "},{"type":"codeinline","content":[{"type":"text","text":"54386"}]},{"type":"text","text":" port ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" Deploy Kubernetes The dashboard "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"GITHUB_URL=https://github.com/kubernetes/dashboard/releases\nVERSION_KUBE_DASHBOARD=$(curl -w '%{url_effective}' -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||')\nkubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/${VERSION_KUBE_DASHBOARD}/aio/deploy/recommended.yaml"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Output is as follows :"}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"namespace/kubernetes-dashboard created\nserviceaccount/kubernetes-dashboard created\nservice/kubernetes-dashboard created\nsecret/kubernetes-dashboard-certs created\nsecret/kubernetes-dashboard-csrf created\nsecret/kubernetes-dashboard-key-holder created\nconfigmap/kubernetes-dashboard-settings created\nrole.rbac.authorization.k8s.io/kubernetes-dashboard created\nclusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created\nrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created\nclusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created\ndeployment.apps/kubernetes-dashboard created\nservice/dashboard-metrics-scraper created\ndeployment.apps/dashboard-metrics-scraper created"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" verification pod Started normally :"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# kubectl get pod -n kubernetes-dashboard\nNAME READY STATUS RESTARTS AGE\ndashboard-metrics-scraper-6b4884c9d5-ltk42 1/1 Running 0 14m\nkubernetes-dashboard-7d8574ffd9-sptn6 1/1 Running 0 98s"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":" The dashboard RBAC To configure "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"️ important :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Created in this guide "},{"type":"codeinline","content":[{"type":"text","text":"admin-user"}]},{"type":"text","text":" Will have permissions in the dashboard ."}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Create the following resource manifest file :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"vi dashboard.admin-user.yml\n\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n name: admin-user\n namespace: kubernetes-dashboard"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"vi dashboard.admin-user-role.yml\n\napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: admin-user\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n - kind: ServiceAccount\n name: admin-user\n namespace: kubernetes-dashboard"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Deploy "},{"type":"codeinline","content":[{"type":"text","text":"admin-user"}]},{"type":"text","text":" To configure :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":" kubectl create -f dashboard.admin-user.yml -f dashboard.admin-user-role.yml"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":" get Bearer Token"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":" kubectl -n kubernetes-dashboard describe secret admin-user-token | grep ^token"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" give the result as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"yaml"},"content":[{"type":"text","text":" token:      eyJhbGciOiJSUzI1NiIsImtpZCI6Im9XNENjc0VlSzVBTDJGRWpPT2VuY1pkbzNJblYybFFwY2YxQnBvZVlMVlEifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXA1Y253Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI0NmI4NGFkYS02MDQ3LTQzN2EtODk2My1lY2NmZWQ4MjE0ZDQiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.N8Zhsf2JU5Hoa8yfhrspJbMGP7AFmfs2JeWXVpDksAEMfWf5mI-MXYcqMkbZ9_Qbwp-h9S7k7oZE41lUp8UXlDWi0Ovm4I4fsuoWqq-aJoyt-c060bWNla1edVZ5BzMTanIYzJHPjS7-cOnsxqg-EtXfdN3JRsiE0QevLvJLhYU37HFc7-cImJ8iH8-r-GHCD8MmuBbTV0EBidLmSo-BdWC5hcZoYghgNtfnMkN0p1e3O23EPRO2XDmaw_lVN4TNgZXPS9hirBD1AZxm1ZE1Iyo2mSOgYjCNQOF8IcaUtjTGqt4RzK4R9AWRbL9z-HMbK_JamcQvDz3fnW3aauCezQ"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":" Access the dashboard locally :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":" kubectl proxy"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The dashboard can now be accessed at the following address :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":""},"content":[{"type":"text","text":" http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/\n   Use admin-user Bearer Token Sign In"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/be/be0e5f973af4d205a982b5b9d675564b.png","alt":"image-20201107213623363","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":" More dashboard access "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"codeinline","content":[{"type":"text","marks":[{"type":"strong"}],"text":"port-forward"}]},{"type":"text","text":" The way "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":" $ kubectl port-forward $(kubectl get pods --selector \"k8s-app=kubernetes-dashboard\" --output=name -n kubernetes-dashboard) --address 0.0.0.0 8443:8443 -n kubernetes-dashboard"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Helm Deploy the application "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# helm repo add stable http://mirror.azure.cn/kubernetes/charts\n# helm repo update\n# helm install jenkins stable/jenkins\nWARNING: This chart is deprecated\nNAME: jenkins\nLAST DEPLOYED: Sat Nov 7 22:25:02 2020\nNAMESPACE: default\nSTATUS: deployed\nREVISION: 1\nNOTES:\n*******************\n****DEPRECATED*****\n*******************\n* The Jenkins chart is deprecated. Future development has been moved to https://github.com/jenkinsci/helm-charts\n\n1. Get your 'admin' user password by running:\n printf $(kubectl get secret --namespace default jenkins -o jsonpath=\"{.data.jenkins-admin-password}\" | base64 --decode);echo\n2. Get the Jenkins URL to visit by running these commands in the same shell:\n export POD_NAME=$(kubectl get pods --namespace default -l \"app.kubernetes.io/component=jenkins-master\" -l \"app.kubernetes.io/instance=jenkins\" -o jsonpath=\"{.items[0].metadata.name}\")\n echo http://127.0.0.1:8080\n kubectl --namespace default port-forward $POD_NAME 8080:8080\n\n3. Login with the password from step 1 and the username: admin\n\n4. Use Jenkins Configuration as Code by specifying configScripts in your values.yaml file, see documentation: http:///configuration-as-code and examples: https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos\n\nFor more information on running Jenkins on Kubernetes, visit:\nhttps://cloud.google.com/solutions/jenkins-on-container-engine\nFor more information about Jenkins Configuration as Code, visit:\nhttps://jenkins.io/projects/jcasc/"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" summary "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" adopt K3S/K3D, There are the following advantages :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":null,"normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":" establish , Deploy , It's fast to start the cluster ;"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":" Cluster consumes less resources ;"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","text":" The created cluster has perfect basic functions ;"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":4,"align":null,"origin":null},"content":[{"type":"text","text":" Can provide and standard K8S Cluster consistent :"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢