开源软件名称(OpenSource Name):kinvolk-archives/kubernetes-the-hard-way-vagrant开源软件地址(OpenSource Url):https://github.com/kinvolk-archives/kubernetes-the-hard-way-vagrant开源编程语言(OpenSource Language):Shell 100.0%开源软件介绍(OpenSource Introduction):Kubernetes The Hard Way (Vagrant)Vagrant configuration and scripts for a Kubernetes setup, the hard way. The setup follows https://github.com/kelseyhightower/kubernetes-the-hard-way with the following exceptions:
Please note that KTHW is a project to learn Kubernetes from bottom up and is not per se a guide to build clusters for production use! Requirements Host
SetupManuallyTo learn Kubernetes from the bottom up, it's recommended to go through
KTHW manually. The The following KTHW parts can/should be skipped:
The scripts in Single script
If everything looks good, continue with "Using the cluster" Multiple scriptsRemove previously created certificates, tools kubeconfig files:
Generate the required certificates:
Generate the kubeconfig files (as those include copies of the previously generated certificates):
Download required tools and files:
Start the virtual machines (optionally, go drink a coffee or tee):
$ vagrant status
Current machine states:
controller-0 running (virtualbox)
controller-1 running (virtualbox)
controller-2 running (virtualbox)
worker-0 running (virtualbox)
worker-1 running (virtualbox)
worker-2 running (virtualbox) Setup etcd on the controller nodes:
SSH into the first controller node: vagrant ssh controller-0 Verify if the etcd is up: sudo -i
export ETCDCTL_API=3
export endpoints=https://192.168.199.10:2379,https://192.168.199.11:2379,https://192.168.199.12:2379
export cacert=/etc/etcd/ca.pem
export cert=/etc/etcd/kubernetes.pem
export key=/etc/etcd/kubernetes-key.pem # etcdctl member list --cacert=$cacert --cert=$cert --key=$key --endpoints=$endpoints
6c500a9f4f9113de, started, controller-0, https://192.168.199.10:2380, https://192.168.199.10:2379, false
e206d150eae73959, started, controller-2, https://192.168.199.12:2380, https://192.168.199.12:2379, false
e7e775a3da74a469, started, controller-1, https://192.168.199.11:2380, https://192.168.199.11:2379, false
# etcdctl endpoint health --cacert=$cacert --cert=$cert --key=$key --endpoints=$endpoints
https://192.168.199.10:2379 is healthy: successfully committed proposal: took = 9.551077ms
https://192.168.199.11:2379 is healthy: successfully committed proposal: took = 11.362935ms
https://192.168.199.12:2379 is healthy: successfully committed proposal: took = 13.922045ms Setup the controller services:
Configure a
Verify controllers are up and running: $ kubectl get componentstatuses
NAME STATUS MESSAGE ERROR
controller-manager Healthy ok
scheduler Healthy ok
etcd-1 Healthy {"health": "true"}
etcd-2 Healthy {"health": "true"}
etcd-0 Healthy {"health": "true"}
[...] Create
Setup the worker binaries, services and configuration:
See if the nodes are ready: $ kubectl get nodes
NAME STATUS ROLES AGE VERSION
worker-0 Ready <none> 53s v1.20.2
worker-1 Ready <none> 33s v1.20.2
worker-2 Ready <none> 11s v1.20.2 Using the clusterSetup DNS add-onDeploy the DNS add-on and verify it's working:
Smoke tests$ kubectl create -f ./manifests/nginx.yaml
deployment "nginx" created
service "nginx" created $ NODE_PORT=$(kubectl get svc nginx --output=jsonpath='{range .spec.ports[0]}{.nodePort}')
$ for i in {0..2}; do curl -sS 192.168.199.2${i}:${NODE_PORT} | awk '/<h1>/{gsub("<[/]*h1>", ""); print $0}'; done
Welcome to nginx!
Welcome to nginx!
Welcome to nginx! Connect to services from host
Traefik loadbalancerUse
To test traefik is actually doing its job, you can create an ingress rule for the nginx service that you created above:
ContributingContributions are welcome: KTHW Vagrant is meant to be a learning project and testbed for aspiring Kubernetes operators and CKAs (Certified Kubernetes Administrator). If you want to contribute code or updates, look for the label good first issue. PitfallsError loading config file "/var/log": read /var/log: is a directoryOn OSX, |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论