Provides Kubernetes installation and configuration on Openshift Origin 3.11 platform. Includes Openshift Origin 3.11 installation steps, Docker configurations, network plugins and RBAC settings. Prepares the necessary Kubernetes environment for Apinizer installation.
sudo apt update
# It is recommended that the following tools be installed on all servers
sudo apt install -y curl wget net-tools gnupg2 software-properties-common apt-transport-https ca-certificates
# Apinizer user is created and authorized.
sudo adduser apinizer
sudo usermod -aG sudo apinizer
# Switch to user and continue operations.
su - apinizer
# Firewall is turned off.
sudo systemctl stop ufw
sudo systemctl disable ufw
# Kubernetes, MongoDB and Elasticsearch do not want swap usage in the operating system in common. Let's disable swap for this.
# To disable swap in running system
sudo swapoff -a
# The swap line in /etc/fstab file is deleted or commented out so that swap does not open when the system restarts.
# Then close the vi file (:wq)
sudo vi /etc/fstab
# For permanent loading of modules
sudo tee /etc/modules-load.d/k8s.conf <<EOF
overlay
br_netfilter
EOF
# To load modules in the running system
sudo modprobe overlay
sudo modprobe br_netfilter
sudo vi /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward=1
net.ipv4.tcp_max_syn_backlog=40000
net.core.somaxconn=40000
net.core.wmem_default=8388608
net.core.rmem_default=8388608
net.ipv4.tcp_sack=1
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_fin_timeout=15
net.ipv4.tcp_keepalive_intvl=30
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_moderate_rcvbuf=1
net.core.rmem_max=134217728
net.core.wmem_max=134217728
net.ipv4.tcp_mem=134217728 134217728 134217728
net.ipv4.tcp_rmem=4096 277750 134217728
net.ipv4.tcp_wmem=4096 277750 134217728
net.core.netdev_max_backlog=300000
sudo apt update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install -y containerd.io docker-ce docker-ce-cli
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo tee /etc/docker/daemon.json <<EOF
{
"insecure-registries" : [ "172.30.0.0/16" ],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl enable docker
sudo groupadd docker
sudo gpasswd -a $USER docker
wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
#Uncompress downloaded file.
tar xvf openshift-origin-client-tools*.tar.gz
cd openshift-origin-client*/
sudo mv oc kubectl /usr/local/bin/
#Verify installation of OpenShift client utility.
oc version
sudo systemctl restart docker
oc cluster up --public-hostname=YOURHOSTIP
oc login -u system:admin
oc adm policy add-cluster-role-to-user cluster-admin developer
oc login
apt install bash-completion
source /usr/share/bash-completion/bash_completion
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
mkdir -p $HOME/.kube
sudo chown -R $(id -u):$(id -g) $HOME/.kube
oc apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
oc get node
NAME STATUS ROLES AGE VERSION
localhost Ready <none> 5d v1.11.0+d4cacc0
apiVersion: v1
kind: Namespace
metadata:
name: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kube-system
oc apply -f service.yaml
oc apply -f adminuser.yaml
oc create clusterrolebinding permissive-binding --clusterrole=cluster-admin --user=admin --user=kubelet --group=system:serviceaccounts
oc create clusterrolebinding apinizer -n kube-system --clusterrole=cluster-admin --serviceaccount=kube-system:apinizer
oc apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml