cd vagrant
vagrant up
Check file "Vagrantfile" about the virtual Machine detail
Check file "scripts/setup.sh" about the the system config and basic software install
SSH To master node virtual machine:
cd vagrant
vagrant ssh k8s-master
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version=1.27.5 --apiserver-advertise-address=192.168.66.11
Install Network plugin List Of Network plugin Deploy Flannel Manually
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
k edit -n kube-flannel daemonsets.apps kube-flannel-ds
add "--iface=enp0s8" in the container args
SSH To master node virtual machine:
cd vagrant
vagrant ssh k8s-worker1 #k8s-worker2
Join Worker Node (See the output detail after the master node kubeadm init)
kubeadm join 192.168.66.11:6443 --token 45m6yx.7csfbt****** \
--discovery-token-ca-cert-hash sha256:94a3bbe5e851ca3f0e36*******
echo 'source <(kubectl completion bash)' >>~/.bashrc
echo 'alias k=kubectl' >>~/.bashrc
echo 'complete -o default -F __start_kubectl k' >>~/.bashrc
source ~/.bashrc
Other Common Use Alais (add to .bashrc manual)
alias kg="kubectl get"
alias kx='f() { [ "$1" ] && kubectl config use-context $1 || kubectl config get-contexts ; } ; f'
alias kn='f() { [ "$1" ] && kubectl config set-context --current --namespace $1 || kubectl config view --minify | grep namespace | cut -d" " -f6 ; } ; f'
[install ingress by helm] (https://kubernetes.github.io/ingress-nginx/deploy/#quick-start)
helm upgrade --install ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx --create-namespace
install MetalLB to add EXTERNAL-IP for local ingress
helm repo add metallb https://metallb.github.io/metallb
helm install metallb metallb/metallb -n metallb-system --create-namespace
kubectl apply -f <(echo '
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: first-pool
namespace: metallb-system
spec:
addresses:
- 192.168.66.200-192.168.66.250
')
kubectl apply -f <(echo '
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: example
namespace: metallb-system
')
kubectl create deployment demo --image=httpd --port=80
kubectl expose deployment demo
kubectl create ingress demo-localhost --class=nginx \
--rule="demo.localdev.me/*=demo:80"
echo "192.168.66.200 demo.localdev.me" >> ~/hosts
try access demo.localdev.me