Skip to content

Commit 545906e

Browse files
committed
Adding k8s directory containing instructions
1 parent 76a265e commit 545906e

11 files changed

+498
-0
lines changed

Diff for: k8s/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# k8s
2+
3+
k8s

Diff for: k8s/ansible-role-k8s

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
http://gbraad.nl/blog/deploying-kubernetes-using-ansible.html

Diff for: k8s/dashboard.yml

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Copyright 2017 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# ------------------- Dashboard Secret ------------------- #
16+
17+
apiVersion: v1
18+
kind: Secret
19+
metadata:
20+
labels:
21+
k8s-app: kubernetes-dashboard
22+
name: kubernetes-dashboard-certs
23+
namespace: kube-system
24+
type: Opaque
25+
26+
---
27+
# ------------------- Dashboard Service Account ------------------- #
28+
29+
apiVersion: v1
30+
kind: ServiceAccount
31+
metadata:
32+
labels:
33+
k8s-app: kubernetes-dashboard
34+
name: kubernetes-dashboard
35+
namespace: kube-system
36+
37+
---
38+
# ------------------- Dashboard Role & Role Binding ------------------- #
39+
40+
kind: Role
41+
apiVersion: rbac.authorization.k8s.io/v1
42+
metadata:
43+
name: kubernetes-dashboard-minimal
44+
namespace: kube-system
45+
rules:
46+
# Allow Dashboard to create 'kubernetes-dashboard-key-holder' secret.
47+
- apiGroups: [""]
48+
resources: ["secrets"]
49+
verbs: ["create"]
50+
# Allow Dashboard to create 'kubernetes-dashboard-settings' config map.
51+
- apiGroups: [""]
52+
resources: ["configmaps"]
53+
verbs: ["create"]
54+
# Allow Dashboard to get, update and delete Dashboard exclusive secrets.
55+
- apiGroups: [""]
56+
resources: ["secrets"]
57+
resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs"]
58+
verbs: ["get", "update", "delete"]
59+
# Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map.
60+
- apiGroups: [""]
61+
resources: ["configmaps"]
62+
resourceNames: ["kubernetes-dashboard-settings"]
63+
verbs: ["get", "update"]
64+
# Allow Dashboard to get metrics from heapster.
65+
- apiGroups: [""]
66+
resources: ["services"]
67+
resourceNames: ["heapster"]
68+
verbs: ["proxy"]
69+
- apiGroups: [""]
70+
resources: ["services/proxy"]
71+
resourceNames: ["heapster", "http:heapster:", "https:heapster:"]
72+
verbs: ["get"]
73+
74+
---
75+
apiVersion: rbac.authorization.k8s.io/v1
76+
kind: RoleBinding
77+
metadata:
78+
name: kubernetes-dashboard-minimal
79+
namespace: kube-system
80+
roleRef:
81+
apiGroup: rbac.authorization.k8s.io
82+
kind: Role
83+
name: kubernetes-dashboard-minimal
84+
subjects:
85+
- kind: ServiceAccount
86+
name: kubernetes-dashboard
87+
namespace: kube-system
88+
89+
---
90+
# ------------------- Dashboard Deployment ------------------- #
91+
92+
kind: Deployment
93+
apiVersion: apps/v1beta2
94+
metadata:
95+
labels:
96+
k8s-app: kubernetes-dashboard
97+
name: kubernetes-dashboard
98+
namespace: kube-system
99+
spec:
100+
replicas: 1
101+
revisionHistoryLimit: 10
102+
selector:
103+
matchLabels:
104+
k8s-app: kubernetes-dashboard
105+
template:
106+
metadata:
107+
labels:
108+
k8s-app: kubernetes-dashboard
109+
spec:
110+
containers:
111+
- name: kubernetes-dashboard
112+
image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0
113+
ports:
114+
- containerPort: 8443
115+
protocol: TCP
116+
args:
117+
- --auto-generate-certificates
118+
# Uncomment the following line to manually specify Kubernetes API server Host
119+
# If not specified, Dashboard will attempt to auto discover the API server and connect
120+
# to it. Uncomment only if the default does not work.
121+
# - --apiserver-host=http://my-address:port
122+
volumeMounts:
123+
- name: kubernetes-dashboard-certs
124+
mountPath: /certs
125+
# Create on-disk volume to store exec logs
126+
- mountPath: /tmp
127+
name: tmp-volume
128+
livenessProbe:
129+
httpGet:
130+
scheme: HTTPS
131+
path: /
132+
port: 8443
133+
initialDelaySeconds: 30
134+
timeoutSeconds: 30
135+
volumes:
136+
- name: kubernetes-dashboard-certs
137+
secret:
138+
secretName: kubernetes-dashboard-certs
139+
- name: tmp-volume
140+
emptyDir: {}
141+
serviceAccountName: kubernetes-dashboard
142+
# Comment the following tolerations if Dashboard must not be deployed on master
143+
tolerations:
144+
- key: node-role.kubernetes.io/master
145+
effect: NoSchedule
146+
147+
---
148+
# ------------------- Dashboard Service ------------------- #
149+
150+
kind: Service
151+
apiVersion: v1
152+
metadata:
153+
labels:
154+
k8s-app: kubernetes-dashboard
155+
name: kubernetes-dashboard
156+
namespace: kube-system
157+
spec:
158+
ports:
159+
- port: 443
160+
targetPort: 8443
161+
selector:
162+
k8s-app: kubernetes-dashboard

Diff for: k8s/ingress

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-ingress-guide-nginx-example.html

Diff for: k8s/init

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
Your Kubernetes master has initialized successfully!
4+
5+
To start using your cluster, you need to run the following as a regular user:
6+
7+
mkdir -p $HOME/.kube
8+
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
9+
sudo chown $(id -u):$(id -g) $HOME/.kube/config
10+
11+
You should now deploy a pod network to the cluster.
12+
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
13+
https://kubernetes.io/docs/concepts/cluster-administration/addons/
14+
15+
You can now join any number of machines by running the following on each node
16+
as root:
17+
18+
kubeadm join 172.31.15.174:6443 --token 1jw4fh.66ohpzmh0zn5dh6c --discovery-token-ca-cert-hash sha256:d7783f9141a57184fcfbaff3cfdfebad3215e0cfd5ca06eac43cbf80181e837b

Diff for: k8s/k8s-dashboard

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
latest:
2+
https://kubernetestutorials.com/how-to-install-kubernetes-dashboard/
3+
4+
dashboard setup:
5+
6+
https://docs.aws.amazon.com/eks/latest/userguide/dashboard-tutorial.html
7+
8+
signin issue:
9+
10+
https://github.com/kubernetes/dashboard/wiki/Accessing-Dashboard---1.7.X-and-above
11+
12+
https://github.com/kubernetes/dashboard/issues/2735
13+
14+
https://docs.giantswarm.io/guides/install-kubernetes-dashboard/
15+
16+
17+
18+
dashboard-token:
19+
https://github.com/kubernetes/dashboard/wiki/Creating-sample-user#bearer-token
20+
21+
https://stackoverflow.com/questions/46664104/how-to-sign-in-kubernetes-dashboard
22+
23+
24+
# Create service account
25+
kubectl create serviceaccount cluster-admin-dashboard-sa
26+
27+
# Bind ClusterAdmin role to the service account
28+
kubectl create clusterrolebinding cluster-admin-dashboard-sa \
29+
--clusterrole=cluster-admin \
30+
--serviceaccount=default:cluster-admin-dashboard-sa
31+
32+
# Parse the token
33+
TOKEN=$(kubectl describe secret $(kubectl -n kube-system get secret | awk '/^cluster-admin-dashboard-sa-token-/{print $1}') | awk '$1=="token:"{print $2}')
34+
35+
36+
$ kubectl -n kube-system edit service kubernetes-dashboard
37+
38+
You should see yaml representation of the service.
39+
Change type: ClusterIP to type: NodePort and save file.
40+
If it's already changed go to next step.
41+
42+
$ kubectl -n kube-system get service kubernetes-dashboard

Diff for: k8s/k8s-master

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
3+
##########################
4+
5+
steps to follow to install kube master:
6+
7+
apt-get update && apt-get install -y apt-transport-https && \
8+
apt install docker.io -y && \
9+
systemctl start docker && \
10+
systemctl enable docker && \
11+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
12+
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
13+
deb http://apt.kubernetes.io/ kubernetes-xenial main
14+
EOF && \
15+
apt-get update && \
16+
apt-get install -y kubelet kubeadm kubectl kubernetes-cni
17+
18+
19+
kubeadm init --ignore-preflight-errors all
20+
mkdir -p $HOME/.kube && \
21+
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config && \
22+
sudo chown $(id -u):$(id -g) $HOME/.kube/config
23+
kubectl apply -f https://docs.projectcalico.org/v3.4/getting-started/kubernetes/installation/hosted/calico.yaml
24+
kubectl get pods --all-namespaces
25+
kubectl get nodes
26+
27+
refer: https://github.com/kubernetes/dashboard
28+
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
29+
30+
#kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
31+
32+
#kubectl proxy --address 0.0.0.0 --accept-hosts '.*' &
33+
34+
35+
#Access the dashboard using the below link
36+
37+
#http://<ip>:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default
38+
39+
40+
# Create service account
41+
kubectl create serviceaccount cluster-admin-dashboard-sa
42+
43+
# Bind ClusterAdmin role to the service account
44+
kubectl create clusterrolebinding cluster-admin-dashboard-sa \
45+
--clusterrole=cluster-admin \
46+
--serviceaccount=default:cluster-admin-dashboard-sa
47+
48+
# Parse the token
49+
TOKEN=$(kubectl describe secret $(kubectl -n kube-system get secret | awk '/^cluster-admin-dashboard-sa-token-/{print $1}') | awk '$1=="token:"{print $2}')
50+
51+
52+
$ kubectl -n kube-system edit service kubernetes-dashboard
53+
54+
You should see yaml representation of the service.
55+
Change type: ClusterIP to type: NodePort and save file.
56+
If it's already changed go to next step.
57+
58+
$ kubectl -n kube-system get service kubernetes-dashboard

Diff for: k8s/k8s-workernode

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
steps to follow to install kube master:
3+
4+
apt-get update && apt-get install -y apt-transport-https && \
5+
apt install docker.io -y && \
6+
systemctl start docker && \
7+
systemctl enable docker && \
8+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
9+
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
10+
deb http://apt.kubernetes.io/ kubernetes-xenial main
11+
EOF && \
12+
apt-get update && \
13+
apt-get install -y kubelet kubeadm kubectl kubernetes-cni
14+
kubeadm join 172.31.26.24:6443 --token hpnfgz.52pq3e95hrsz68c6 --discovery-token-ca-cert-hash sha256:92f783e806fb2b0bd36c2847d276847e78a14e07f86256cdbb4f3d79b9618df8
15+
16+
masterside to fecth the token:
17+
kubeadm token create --print-join-command
18+

Diff for: k8s/links

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
setup:
3+
https://www.linkedin.com/pulse/automated-service-deployment-using-jenkins-kubernetes-ganaesan
4+
commands:
5+
https://kubernetes.io/docs/reference/kubectl/cheatsheet/
6+
7+
connect to pods:
8+
9+
https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/
10+
11+
prometheus:
12+
https://devopscube.com/setup-prometheus-monitoring-on-kubernetes/
13+
14+
https://prometheus.io/docs/introduction/overview/

Diff for: k8s/readme

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
3+
https://www.linkedin.com/pulse/automated-service-deployment-using-jenkins-kubernetes-ganaesan
4+
5+
https://blog.tekspace.io/kubernetes-dashboard-remote-access/
6+
7+
8+
to authenticate:
9+
10+
https://devops.stackexchange.com/questions/3537/how-to-login-to-k8s-proxy-nowadays?rq=1
11+
12+
cat dashboard-rolebinding.yaml
13+
14+
apiVersion: rbac.authorization.k8s.io/v1beta1
15+
kind: ClusterRoleBinding
16+
metadata:
17+
name: kubernetes-dashboard
18+
labels:
19+
k8s-app: kubernetes-dashboard
20+
roleRef:
21+
apiGroup: rbac.authorization.k8s.io
22+
kind: ClusterRole
23+
name: cluster-admin
24+
subjects:
25+
- kind: ServiceAccount
26+
name: kubernetes-dashboard
27+
namespace: kube-system
28+
29+
30+
kubectl create -f dashboard-rolebinding.yaml
31+
32+
33+
34+
stop proxy:
35+
netstat -tulp | grep kubectl
36+
Then run sudo kill -9 <pid> to kill the process.
37+

0 commit comments

Comments
 (0)