Created
June 18, 2021 09:59
-
-
Save ootput/5329639ddb58067ad09552c7833c8ea3 to your computer and use it in GitHub Desktop.
kubevip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| k3sup install \ | |
| --host=172.16.10.11 \ | |
| --user=ootput \ | |
| --k3s-version=v1.21.1+k3s1 \ | |
| --local-path=config.minipcarmy.yaml \ | |
| --context minipcarmy \ | |
| --cluster \ | |
| --tls-san 172.16.10.5 \ | |
| --k3s-extra-args="--disable servicelb --node-taint node-role.kubernetes.io/master=true:NoSchedule" | |
| kcc -f config.minipcarmy.yaml | |
| ssh root@172.16.10.11 | |
| curl -s https://kube-vip.io/manifests/rbac.yaml > /var/lib/rancher/k3s/server/manifests/kube-vip-rbac.yaml | |
| # edit kube-vip-rbac.yaml | |
| - apiGroups: ["coordination.k8s.io"] | |
| resources: ["leases"] | |
| verbs: ["list", "get", "watch", "update", "create"] | |
| ifconfig ens18 | |
| export VIP=172.16.10.5 | |
| export INTERFACE=ens18 | |
| # fetch container | |
| crictl pull docker.io/plndr/kube-vip:0.3.2 | |
| # create alias | |
| alias kube-vip="ctr run --rm --net-host docker.io/plndr/kube-vip:0.3.2 vip /kube-vip" | |
| # generate manifest | |
| kube-vip manifest daemonset \ | |
| --arp \ | |
| --interface $INTERFACE \ | |
| --address $VIP \ | |
| --controlplane \ | |
| --leaderElection \ | |
| --taint \ | |
| --inCluster | tee /var/lib/rancher/k3s/server/manifests/kube-vip.yaml | |
| # edit kube-vip.yaml | |
| tolerations: | |
| - effect: NoSchedule | |
| key: node-role.kubernetes.io/master | |
| operator: Exists | |
| ping 172.16.10.5 | |
| # edit config.demo.yaml and replace server with 172.16.10.5 | |
| # add remaining server nodes | |
| k3sup join --host=172.16.10.21 --server-user=ootput --server-host=172.16.10.5 --user=ootput --k3s-version=v1.21.1+k3s1 --server --k3s-extra-args="--disable servicelb --node-taint node-role.kubernetes.io/master=true:NoSchedule" | |
| k3sup join --host=172.16.10.31 --server-user=ootput --server-host=172.16.10.5 --user=ootput --k3s-version=v1.21.1+k3s1 --server --k3s-extra-args="--disable servicelb --node-taint node-role.kubernetes.io/master=true:NoSchedule" | |
| k get po -n kube-system | |
| # add worker node | |
| k3sup join --host=172.16.10.41 --server-user=ootput --server-host=172.16.10.5 --user=ootput --k3s-version=v1.21.1+k3s1 | |
| k3sup join --host=172.16.10.42 --server-user=ootput --server-host=172.16.10.5 --user=ootput --k3s-version=v1.21.1+k3s1 | |
| k3sup join --host=172.16.10.51 --server-user=ootput --server-host=172.16.10.5 --user=ootput --k3s-version=v1.21.1+k3s1 | |
| k3sup join --host=172.16.10.52 --server-user=ootput --server-host=172.16.10.5 --user=ootput --k3s-version=v1.21.1+k3s1 | |
| k get po -n kube-system | |
| k get service -n kube-system | |
| K3s Service LoadBalancer Installation | |
| # install metallb | |
| curl -s https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/namespace.yaml > /var/tmp/metallb.yaml; \ | |
| echo '---' >> /var/tmp/metallb.yaml; \ | |
| curl -s https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/metallb.yaml >> /var/tmp/metallb.yaml; \ | |
| mv /var/tmp/metallb.yaml /var/lib/rancher/k3s/server/manifests | |
| # create secret | |
| kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)" | |
| # create configmap | |
| apiVersion: v1 | |
| kind: ConfigMap | |
| metadata: | |
| namespace: metallb-system | |
| name: config | |
| data: | |
| config: | | |
| address-pools: | |
| - name: default | |
| protocol: layer2 | |
| addresses: | |
| - 172.16.10.100-172.16.10.254 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment