-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
kubernetes-cheatsheet.txt
112 lines (83 loc) · 2.97 KB
/
kubernetes-cheatsheet.txt
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
106
107
108
109
110
111
112
/---------------------------------------------------------------\
| Author: Lucian Maly <lucian.maly@oracle.com> |
| Last update: 2016-07-17 |
\---------------------------------------------------------------/
# PREPARE ENVIRONMENT FOR K8S
---------------------------
$ sudo apt-get update
$ sudo apt-gt install python curl
$ curl https://sdk.cloud.google.com | bash
$ gcloud auth login
$ gcloud config list project
$ gcloud config set project <PROJECT ID>
-----------------------------------------------------------------
# INSTALL LATEST K8S VERSION
--------------------------
$ curl -sS https://get.k8s.io | bash
$ $HOME/kubernetes/cluster/kube-up.sh
By default it will use gce provider
By default the cluster will have 4 minions
Configuration is stored:
$ vim $HOME/.kube/config
Binaries by default stored at:
$ $HOME/kubernetes/cluster
-----------------------------------------------------------------
# KUBERNETES UI
-------------
https://<your-master-IP>/api/v1/proxy/namespaces/kube-system/services/kube-ui
-summary of the minions, CPU, memory, used disk space, IP addresses
See the credentials for logging in to the above WebUI:
$ kubectl config view
-----------------------------------------------------------------
# GRAFANA UI
----------
https://<your-master-IP>/api/v1/proxy/namespaces/kube-system/services/monitor-grafana
-summary of the metrics on the cluster nodes - CPU, memory
-----------------------------------------------------------------
# SWAGGER
-------
https://<your-master-IP>/swagger-ui
-summary of the K8s RESTful API
i.e.
https://<your-master-IP>/api/v1/nodes/?pretty=true
https://<your-master-IP>/api/v1/nodes/?pretty=false
-----------------------------------------------------------------
# KUBECTL.SH
----------
-commands to explore our cluster and the workloads running on it
$ cd $HOME/kubernetes/cluster
$ chmod +x kubectl.sh
# Prepend a dot - the program will look in the current directory first, before searching the rest of the PATH
$ export PATH=".:$PATH"
# Append the Kubernetes path to the end:
$ export PATH=$PATH:/home/$USER/kubernetes/cluster
# To make changes permanent, add the export to the end of .bashrc in $HOME
$ ln -s kubectl.sh kubectl
Cluster summary (master, DNS, UI, Grafana, Heapster, InfluxDB) can be viewed by:
$ kubectl cluster-info
Listing the nodes in our cluster:
$ kubectl get nodes
List cluster events:
$ kubectl get events
See services that are running in the cluster:
$ kubectl get services
-you will only see one core API/monitoring/logging service called 'kubernetes' at the beginning
# K8S on AWS
----------
# WORKING WITH PODS
----------
```
# cat my-first-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: my-first-pod
spec:
containers:
- name: my-nginx
image: nginx
- name: my-centos
image: centos
command: ["/bin/sh", "-c", "while : ;do curl http://localhost:80/; sleep 3; done"]
```
kubectl create -f my-first-pod.yaml pod "my-first-pod" created