Welcome About

How to install K8S

which_server

All Machines!!!

1
hostnamectl set-hostname k8smaster.xurupita.nl
1
hostnamectl set-hostname k8snode.xurupita.nl

Disable the SELinux:

1
2
sed -e 's/SELINUX=.*/SELINUX=permissive/' /etc/selinux/config -i setenforce 0

And the FirewallD:

1
2
systemctl stop firewalld systemctl disable firewalld
1
2
3
4
5
6
7
8
9
10
cat << 'EOF' > /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.88.80 k8smaster.xurupita.nl k8smaster 192.168.88.81 k8snode.xurupita.nl k8snode 192.168.88.41 simplecontroller.xurupita.nl simplecontroller 192.168.88.42 simplecompute.xurupita.nl simplecompute 192.168.88.43 simplezuncontroller.xurupita.nl simplezuncontroller 192.168.88.44 simplezuncompute.xurupita.nl simplezuncompute EOF
1
swapoff -a
1
yum install epel-release -y
1
yum install docker -y
1
2
systemctl enable docker systemctl start docker
1
2
3
4
cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF
1
sysctl --system
1
2
3
4
5
6
7
8
9
cat << 'EOF' > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-$basearch enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOF
1
yum install kubeadm kubelet kubectl -y
1
systemctl enable kubelet
1
2
3
4
5
6
kubectl completion bash > /etc/bash_completion.d/kubectl.bash kubeadm completion bash > /etc/bash_completion.d/kubeadm.bash source /etc/bash_completion.d/kubectl.bash source /etc/bash_completion.d/kubeadm.bash
which_server

k8smaster

1
kubeadm config images pull
1
kubeadm init --apiserver-advertise-address=192.168.88.80 --pod-network-cidr=10.248.248.0/24
1
2
mkdir -p $HOME/.kube cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
1
kubectl apply -f https://docs.projectcalico.org/v3.10/manifests/calico.yaml
1
kubectl get nodes
1
kubectl get pods --all-namespaces
1
2
token=$(kubeadm token list | awk ' ! /TOKEN/ {print $1}') shacert="sha256:$(openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //')"
1
ssh k8snode kubeadm join 192.168.88.20:6443 --token $token --discovery-token-ca-cert-hash $shacert
1
kubectl get nodes
1
kubectl run test-nginx --image=nginx --replicas=2 --port=80
1
kubectl expose deployment test-nginx
1
kubectl get services
1
kubectl describe service test-nginx
1
kubectl get pods
1
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
1
kubectl proxy --address=0.0.0.0 --accept-hosts='.*' &