0% found this document useful (0 votes)
93 views7 pages

Creation de Cluster

This document provides steps to set up a Kubernetes cluster with a master node and slave node, install Docker and Kubernetes components, initialize the master node, join the slave node to the cluster, and deploy a sample formulaire deployment and service. Key steps include configuring hostnames and /etc/hosts, generating SSH keys, initializing the master with kubeadm, copying the kubeconfig file, installing Calico for networking, deploying the Kubernetes dashboard, and joining the slave node to the cluster.

Uploaded by

Amine Boubakeur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views7 pages

Creation de Cluster

This document provides steps to set up a Kubernetes cluster with a master node and slave node, install Docker and Kubernetes components, initialize the master node, join the slave node to the cluster, and deploy a sample formulaire deployment and service. Key steps include configuring hostnames and /etc/hosts, generating SSH keys, initializing the master with kubeadm, copying the kubeconfig file, installing Calico for networking, deploying the Kubernetes dashboard, and joining the slave node to the cluster.

Uploaded by

Amine Boubakeur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

$ sudo su

# apt-get update
# swapoff -a
# nano /etc/hostname

hostnamectl set-hostname "master"

exec bash

hostnamectl set-hostname "slave"

exec bash

# nano /etc/hosts
192.168.100.100 master
192.168.100.101 slave
# sudo apt-get install openssh-server
$ssh-keygen -t rsa -b 4096 -C "102Chedi"
$ ssh-agent
$ ssh-copy-id [email protected]

# apt-get update
# apt-get install -y docker.io

~$ sudo systemctl start docker

~$ sudo systemctl enable docker

# apt-get update && apt-get install -y apt-transport-https curl


# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
# cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
# apt-get update
# apt-get install -y kubelet kubeadm kubectl 
# nano /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
Environment=”cgroup-driver=systemd/cgroup-driver=cgroupfs”
# kubeadm init --apiserver-advertise-address=192.168.100.100 --pod-network-
cidr=192.168.0.0/16

$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

$ kubectl get pods -o wide --all-namespaces


$ kubectl apply -f https://docs.projectcalico.org/v3.7/manifests/calico.yaml
$ kubectl apply -f
https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommen
ded/kubernetes-dashboard.yaml

$ kubectl proxy
$ kubectl create serviceaccount dashboard -n default
$ kubectl create clusterrolebinding dashboard-admin -n default --clusterrole=cluster-admin
--serviceaccount=default:dashboard
$ kubectl get secret $(kubectl get serviceaccount dashboard -o jsonpath="{.secrets[0].name}")
-o jsonpath="{.data.token}" | base64 --decode

$ sudo kubeadm join --apiserver-advertise-address=172.25.100.40 --pod-network-


cidr=172.100.0.0/16
kubeadm join 192.168.100.100:6443 --token me1etm.7e4bhmozxdm1rc9z --discovery-
token-ca-cert-hash
sha256:4cba0ae5e7ec057d3c266f6b9e7fd2727c6f479a4b541119c85b27a1d52c3939
kubeadm join 172.25.100.40:6443 --token xd3t7i.979rt4u1bpw6f5i7 --discovery-token-ca-
cert-hash sha256:60f0eafd16f6b1b6a4d8fe40a9df3be7f2e38b259baca0f8ab440c77b1fbfdc7
kubeadm join 192.168.100.100:6443 --token g4bhxk.j95zjwfiitl68cjb --discovery-token-ca-
cert-hash
sha256:198e1467ad59c52cb105db828de40b68740f77e9a5069b624903562ef55f8a95
eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2Nvd
W50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhd
Wx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRhc
2hib2FyZC10b2tlbi01eGdwOSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2
VydmljZS1hY2NvdW50Lm5hbWUiOiJkYXNoYm9hcmQiLCJrdWJlcm5ldGVzLmlvL3Nlc
nZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJiYWZhOTVjNy0wOWMyL
TQ1YTItOTM0Ni00OTQ2ODYxMjc1YmIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291
bnQ6ZGVmYXVsdDpkYXNoYm9hcmQifQ.W49oA1VFnJtUaqQ_sXIvtQZDEdtN8fKaiIL
QjKJj-1PUN3RCtO1V5IBtMiPKqlO2WdmtG6fsf-
ZDlDXMopVmgf2c1O3uujXGSp2bsJkKqkqRTAQph7Pe1wQA7bb6i632Uno4nmXJpM0oH
fiawRjEXUePD0pNWX4D7xFpe0JGgxq9MFjH14vmAzxtplka_za6A5rCp9jhoJIsJ0R1neQQ
USw7xB6XB7GTkrfZOF7w3I52A9wxJQs9IVGvQLHIiDOxzuP8nRe24XHBIO5cSYZRwg
9jAKuOIwylFYdUxln_VW2p4QXgjSQ1IznV7G5i6_QEiuO1ZhGr50tBw0eV5tljqQ

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-
dashboard:/proxy/
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "formulaire",
"namespace": "default",
"selfLink": "/apis/extensions/v1beta1/namespaces/default/deployments/formulaire",
"uid": "457a472b-2c1c-4e65-ac7e-6208b24c8e48",
"resourceVersion": "27961",
"generation": 1,
"creationTimestamp": "2019-07-04T19:34:36Z",
"labels": {
"k8s-app": "formulaire"
},
"annotations": {
"deployment.kubernetes.io/revision": "1"
}
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"k8s-app": "formulaire"
}
},
"template": {
"metadata": {
"name": "formulaire",
"creationTimestamp": null,
"labels": {
"k8s-app": "formulaire"
}
},
"spec": {
"containers": [
{
"name": "formulaire",
"image": "nyezza/formulaire",
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always",
"securityContext": {
"privileged": true
}
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": "25%",
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 1,
"replicas": 2,
"updatedReplicas": 2,
"unavailableReplicas": 2,
"conditions": [
{
"type": "Available",
"status": "False",
"lastUpdateTime": "2019-07-04T19:34:37Z",
"lastTransitionTime": "2019-07-04T19:34:37Z",
"reason": "MinimumReplicasUnavailable",
"message": "Deployment does not have minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2019-07-04T19:34:37Z",
"lastTransitionTime": "2019-07-04T19:34:36Z",
"reason": "ReplicaSetUpdated",
"message": "ReplicaSet \"formulaire-59bc6f56b\" is progressing."
}
]
}
}

kind: Deployment
apiVersion: formulaire/v1
metadata:
labels:
app: formulaire
name: formulaire
namespace: default
spec:
replicas: 3
selector:
matchLabels:
app: formulaire
template:
metadata:
labels:
app: formulaire
spec:
containers:
- name: hello
image: docker.io/nyezza/formulaire:34
imagePullPolicy: Always
ports:
- name: http
containerPort: 80
- name: health
containerPort: 81
args:
livenessProbe:
httpGet:
path: /healthz
port: 81
scheme: HTTP
initialDelaySeconds: 15
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /readiness
port: 81
scheme: HTTP
nitialDelaySeconds: 5
timeoutSeconds: 1

You might also like