-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8
105 lines (63 loc) · 2.76 KB
/
k8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
sudo apt-get update && apt-get install -y openssh-server docker.io
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
vim.tiny /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
Environment=”cgroup-driver=systemd/cgroup-driver=cgroupfs”
reboot
>>> ON kMASTER
systemctl start docker.service;systemctl enable docker.service
kubeadm init --apiserver-advertise-address=192.168.56.101 --pod-network-cidr=192.168.0.0/16
To recover lost join command - kubeadm token create --print-join-command
kubectl get pods -o wide --all-namespaces
kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
kubectl -n kube-system edit service kubernetes-dashboard
Change type: ClusterIP to type: NodePort
kubectl -n kube-system get service kubernetes-dashboard
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
http://192.168.56.101:30307/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
Deployment
-----------------------------------------
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
--------------------------------------
kubectl describe deployment nginx-deployment
kubectl describe pod
kubectl get pods -l app=nginx
> Port change
> increase replicas
kubectl delete deployment nginx-deployment
Service
kubectl create service nodeport nginx --tcp=80:80
get svc nginx
RR upgrade
kubectl set image deployment nginx-deployment nginx=hshar/httpd
Ref:
https://github.com/kubernetes/dashboard/wiki/Accessing-Dashboard---1.7.X-and-above
https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/