hello
install k8s with kubeadm
This file contains 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
## containerd prereq | |
modprobe br_netfilter | |
modprobe overlay | |
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf | |
overlay | |
br_netfilter | |
EOF | |
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf | |
net.bridge.bridge-nf-call-iptables = 1 | |
net.ipv4.ip_forward = 1 | |
net.bridge.bridge-nf-call-ip6tables = 1 | |
EOF | |
sysctl --system | |
## install containerd | |
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ | |
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
apt-get update -qq | |
apt-get install -y containerd.io | |
mkdir -p /etc/containerd | |
containerd config default | sudo tee /etc/containerd/config.toml | |
systemctl restart containerd | |
## install kubeadm/kubelet/kubectl | |
curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg | |
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list | |
apt-get update -qq | |
apt-get install -y kubelet kubeadm kubectl | |
## create basic k8s installation | |
kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=FileContent--proc-sys-net-ipv4-ip_forward | |
## install CNI: flannel | |
kubectl --kubeconfig=/etc/kubernetes/admin.conf apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml | |
## untaint master node to be a worker | |
kubectl --kubeconfig=/etc/kubernetes/admin.conf taint node --all node-role.kubernetes.io/master:NoSchedule- | |
## setup completion | |
apt-get install -y bash-completion | |
apt-get install -y bash-completion | |
kubeadm completion bash > /etc/bash_completion.d/kubeadm | |
kubectl completion bash > /etc/bash_completion.d/kubectl | |
echo 'complete -o default -F __start_kubectl k' > /etc/bash_completion.d/k | |
## setup root profile | |
cat >>/root/.bashrc <<EOF | |
alias k=kubectl | |
alias ll='ls -la' | |
export KUBECONFIG=/etc/kubernetes/admin.conf | |
EOF |
This file contains 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
apiVersion: v1 | |
kind: Pod | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: web | |
name: web | |
spec: | |
containers: | |
- image: nginx | |
name: web | |
ports: | |
- containerPort: 80 | |
resources: {} | |
dnsPolicy: ClusterFirst | |
restartPolicy: Always | |
status: {} | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: web | |
name: web | |
spec: | |
ports: | |
- port: 80 | |
protocol: TCP | |
targetPort: 80 | |
nodePort: 30080 | |
selector: | |
run: web | |
type: NodePort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment