Created
October 22, 2018 14:34
-
-
Save germainlefebvre4/7048fe02b301dd677cfa32c0f3db1312 to your computer and use it in GitHub Desktop.
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
# My dependencies | |
yum install -y telnet mlocate | |
# Prepare system | |
setenforce 0 | |
swapoff `cat /etc/fstab | grep swap | awk '{print $1}'` | |
cat <<EOF > /etc/sysctl.d/k8s.conf | |
net.bridge.bridge-nf-call-ip6tables = 1 | |
net.bridge.bridge-nf-call-iptables = 1 | |
EOF | |
sysctl --system | |
# Install Docker | |
# yum install -y docker | |
# systemctl enable docker | |
# systemctl start docker | |
# Install Docker CE | |
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo | |
yum install -y --setopt=obsoletes=0 \ | |
docker-ce-17.03.2.ce-1.el7.centos \ | |
docker-ce-selinux-17.03.2.ce-1.el7.centos | |
systemctl enable docker | |
systemctl start docker | |
systemctl status docker | |
# Prepare install | |
# Might disable repo_gpgcheck attribute | |
cat <<EOF > /etc/yum.repos.d/kubernetes.repo | |
[kubernetes] | |
name=Kubernetes | |
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 | |
enabled=1 | |
gpgcheck=1 | |
repo_gpgcheck=0 | |
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg | |
EOF | |
# Install K8s | |
yum install -y kubelet-1.9.7 kubeadm-1.9.7 kubectl-1.9.7 | |
# yum install -y kubelet-1.11.1 kubeadm-1.11.1 kubectl-1.11.1 | |
sed -i 's/^\(Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=\).*/\1cgroupfs"/g' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | |
systemctl daemon-reload | |
systemctl enable kubelet | |
systemctl restart kubelet | |
systemctl status kubelet | |
# Créer le cluster K8s | |
# Q: 10.244.0.0/16 réseau interne de docker défini par l'utilisateur ? | |
# Might need to add arg: --ignore-preflight-errors=cri | |
kubeadm init --pod-network-cidr 10.244.0.0/16 | |
# kubeadm init --pod-network-cidr 10.244.0.0/16 --ignore-preflight-errors=cri | |
# Q: Actions .kube nécessaires ? Oui, mais pourquoi ? | |
mkdir -p $HOME/.kube | |
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
chown $(id -u):$(id -g) $HOME/.kube/config | |
# Install Network : Flannel | |
# Flannel: https://github.com/coreos/flannel/blob/master/Documentation/kubernetes.md | |
# Q: Avantages de Flannel ? Voir | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml | |
# Join K8s Nodes to Cluster : command given in 'kubeadm init' | |
kubeadm join --token b26bb6.e040d60287e35dc7 192.168.248.166:6443 --discovery-token-ca-cert-hash sha256:0a7dfc557cc247b630ec20e58e3f367f53c27b1411d491542a9395ba2dc48e3a | |
# Install Dashboard | |
# https://github.com/kubernetes/dashboard | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml | |
# /!\ Important: Dashboard do not work through kubectl proxy | |
kubectl proxy --address='ec2-35-158-214-75.eu-central-1.compute.amazonaws.com' --port=80 --accept-hosts='.*' | |
# Browser : http://server:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ | |
# Dashboard: Admin for all | |
# https://github.com/kubernetes/dashboard/wiki/Access-control#login-view | |
cat << EOF > dashboard-admin.yaml | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: kubernetes-dashboard | |
labels: | |
k8s-app: kubernetes-dashboard | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: ClusterRole | |
name: cluster-admin | |
subjects: | |
- kind: ServiceAccount | |
name: kubernetes-dashboard | |
namespace: kube-system | |
EOF | |
kubectl create -f dashboard-admin.yaml | |
# Browser: Skip > Admin rights |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment