Skip to content

Commit 3869520

Browse files
committed
misc commits
1 parent 2f7b775 commit 3869520

File tree

6 files changed

+63
-74
lines changed

6 files changed

+63
-74
lines changed

chapters/3_install_kubernetes.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,19 @@ Selector: app=kubernetes-dashboard
241241
Type: NodePort
242242
IP: 10.98.148.82
243243
Port: <unset> 80/TCP
244-
NodePort: <unset> 32756/TCP
244+
NodePort: <unset> 31000/TCP
245245
Endpoints: 10.40.0.1:9090
246246
Session Affinity: None
247247
```
248248

249-
Now check for the node port, here it is 32756, and go to the browser,
249+
Now check for the node port, here it is 31000, and go to the browser, and access the dashboard with the following URL
250+
`do not use the IP above, use master node IP instead`
251+
250252

251253
```
252-
masterip:32756
254+
http://NODEIP:31000
253255
```
256+
254257
The Dashboard Looks like:
255258

256259
![alt text](images/Kubernetes-Dashboard.png "Kubernetes Dashboard")

chapters/advanced_pod_scheduling.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,14 @@ vote-56bf599b9c-xw7zc 1/1 Running 0 19s 10.233.74.81
363363
You could add the taints with criteria and effects. Effetcs can be
364364

365365
**Taint Specs**:
366-
* effect
367-
* NoSchedule
368-
* PreferNoSchedule
369-
* NoExecute
370-
* key
371-
* value
372-
* timeAdded (only written for NoExecute taints)
366+
367+
* effect
368+
* NoSchedule
369+
* PreferNoSchedule
370+
* NoExecute
371+
* key
372+
* value
373+
* timeAdded (only written for NoExecute taints)
373374

374375

375376

@@ -396,7 +397,7 @@ worker-7c98c96fb4-7tzzw 1/1 Running 1 4h 10.233.75.8
396397
Lets taint a node.
397398

398399
```
399-
kubectl taint node node2 dedicate=worker:NoExecute
400+
kubectl taint node node2 dedicated=worker:NoExecute
400401
```
401402

402403

@@ -434,7 +435,7 @@ apiVersion: apps/v1
434435
image: schoolofdevops/vote-worker:latest
435436
436437
tolerations:
437-
- key: "dedicate"
438+
- key: "dedicated"
438439
operator: "Equal"
439440
value: "worker"
440441
effect: "NoExecute"

chapters/cluster_setup_kubespray.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Kubernetes - Cluster Setup using Kubespray
1+
# High Available Kubernetes Cluster Setup using Kubespray
22

33
Kubespray is an *Ansible* based kubernetes provisioner. It helps us to setup a production grade, highly available and highly scalable Kubernetes cluster.
44

chapters/configuring_authentication_and_authorization.md

Lines changed: 42 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -33,48 +33,6 @@ When a request tries to contact the API , it goes through various stages as illu
3333
<sub>[source: official kubernetes site](https://kubernetes.io/docs/home/)</sub>
3434

3535

36-
### Stage 1: Authentication
37-
38-
* Authentication operation checks whether the *user/service account* has the permission to talk to the api server or not.
39-
* Authentication is done by the authentication modules which are configured with the api server.
40-
* Cluster uses with one or more authentication modules enabled.
41-
* If the request fails to authenticate itself, it will be served with **401 error**.
42-
43-
#### Authentication for Human Users
44-
45-
* Kubernetes uses **usernames** for access control.
46-
* But it neither has an api object nor stores information about users in its data store.
47-
* Users need to be managed externally by the cluster administrator.
48-
49-
#### Authentication for Service Accounts
50-
51-
* Unlike user accounts, service accounts are managed by Kubernetes.
52-
* *service accounts* are bound to specific namespaces.
53-
* Credentials for *service Accounts* are stored as *secrets*.
54-
* These secrets are mounted to pods when a deployment starts using the Service Account.
55-
56-
### Stage 2: Authorization
57-
58-
* After a request successfully authenticated, it goes through the authorization process.
59-
* In order for a request to be authorized, it must consist following attributes.
60-
* Username of the requester(User)
61-
* Requested action(Verb)
62-
* The object affected(Resource)
63-
* Authorization is done by the following modules. Each of these modules has a special purpose.
64-
* Attribute Based Access Control(ABAC)
65-
* Role Based Access Control(RBAC)
66-
* Node Authorizer
67-
* Webhook module
68-
* If a request is failed to get authorized, it will be served with **403 error**.
69-
* Among these modules, RBAC is the most used authorizer while,
70-
* ABAC is used for,
71-
* Policy based, fine grained access control
72-
* The caveat is api server has to be restarted whenever we define a ABAC policy
73-
* Node Authorizer is,
74-
* Enabled in all the worker nodes
75-
* Grants access to kubelet for some of the resources.
76-
* We have already talked about the user in detail. Now lets focus on **verbs** and **resources**
77-
* We will talk about RBAC in detail in the later part
7836

7937
## api groups and resources
8038

@@ -95,11 +53,6 @@ When a request tries to contact the API , it goes through various stages as illu
9553

9654
In addition to the above apiGroups, you may see **extensions** being used in some example code snippets. Please note that **extensions** was initially created as a experiement and is been deprecated, by moving most of the matured apis to one of the groups mentioned above. [You could read this comment and the thread](https://github.com/kubernetes/kubernetes/issues/43214#issuecomment-287143011) to get clarity on this.
9755

98-
### Stage 3: Admission Control
99-
* Admission control part is taken care of by the software modules that can modify/reject requests.
100-
* Admission control is mainly used for fine-tuning access control.
101-
* Admission control can directly act on the object being modified.
102-
10356

10457
## Role Based Access Control (RBAC)
10558

@@ -194,7 +147,9 @@ Assuming all the files are in the same directory, sign the CSR as,
194147

195148
```
196149
openssl x509 -req -CA ca.pem -CAkey ca-key.pem -CAcreateserial -days 730 -in maya.csr -out maya.crt
150+
197151
openssl x509 -req -CA ca.pem -CAkey ca-key.pem -CAcreateserial -days 730 -in kim.csr -out kim.crt
152+
198153
openssl x509 -req -CA ca.pem -CAkey ca-key.pem -CAcreateserial -days 730 -in yono.csr -out yono.crt
199154
```
200155

@@ -212,15 +167,22 @@ In order to configure the users that you created above, following steps need to
212167
to add credentials,
213168

214169
```
215-
kubectl config set-credentials maya --client-certificate=~/.kube/users/maya.crt --client-key=~/.kube/users/maya.key
170+
kubectl config set-credentials maya --client-certificate=/absolute/path/to/maya.crt --client-key=/absolute/path/to/maya.key
216171
217-
kubectl config set-credentials kim --client-certificate=~/.kube/users/kim.crt --client-key=~/.kube/users/kim.key
172+
kubectl config set-credentials kim --client-certificate=/absolute/path/to/kim.crt --client-key=~/.kube/users/kim.key
218173
219-
kubectl config set-credentials yono --client-certificate=~/.kube/users/yono.crt --client-key=~/.kube/users/yono.key
174+
kubectl config set-credentials yono --client-certificate=/absolute/path/to/yono.crt --client-key=~/.kube/users/yono.key
220175
221176
```
222177

223-
and to define context (user@cluster). If you are not sure whats the cluster name, use the following command to find,
178+
where,
179+
180+
* Replace /absolute/path/to/ with the path to these files.
181+
* `invalid` : ~/.kube/users/yono.crt
182+
* `valid` : /home/xyz/.kube/users/yono.crt
183+
184+
185+
And proceed to set/create contexts (user@cluster). If you are not sure whats the cluster name, use the following command to find,
224186

225187
```
226188
kubectl config get-contexts
@@ -240,9 +202,11 @@ where, **prod**, **cluster4** and **kubernetes** are cluster names.
240202
To set context for **prod** cluster,
241203

242204
```
243-
kubectl config set-context maya-prod --cluster=prod --user=maya
244-
kubectl config set-context kim-prod --cluster=prod --user=kim
245-
kubectl config set-context yono-prod --cluster=prod --user=yono
205+
kubectl config set-context maya-prod --cluster=prod --user=maya --namespace=instavote
206+
207+
kubectl config set-context kim-prod --cluster=prod --user=kim --namespace=instavote
208+
209+
kubectl config set-context yono-prod --cluster=prod --user=yono --namespace=instavote
246210
247211
```
248212

@@ -397,17 +361,37 @@ roleRef:
397361

398362

399363
```
400-
kubectl create -f readonly-role.yml
364+
kubectl create -f interns-role.yml
401365
402-
kubectl create -f readonly-rolebinding.yml
366+
kubectl create -f interns-rolebinding.yml
403367
```
404368

405-
And validate
369+
To gt information about the objects created above,
406370

407371
```
408372
kubectl get roles -n instavote
409373
kubectl get roles,rolebindings -n instavote
410374
411-
kubectl get pods -n instavote --as-group=example.org --as=yono
375+
kubectl describe role interns
376+
kubectl describe rolebinding interns
377+
378+
```
412379

380+
To validate the access,
413381
```
382+
kubectl config use-context yono-prod
383+
kubectl get pods
384+
385+
```
386+
387+
To switch back to admin,
388+
389+
```
390+
kubectl config use-context admin-prod
391+
392+
```
393+
394+
#### Exercise
395+
396+
397+
Create a Role and Rolebinding for **dev** group with the authorizations defined in the table above. Once applied, test it

chapters/kubespray-prereqs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Provisioning vagrant based setup for Kubespray
1+
# Provisioning HA Lab Cluster with Vagrant
22

33
## Vagrant Setup:
44

mkdocs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pages:
66
- Provisioning VMs with Vagrant: "2_kube_cluster_vagrant.md"
77
- Setup Kubernetes Cluster: "3_install_kubernetes.md"
88
- Kuberentes Visualizer : "kube_visualizer.md"
9+
- Kubernetes Quickdive: "quickdive.md"
910
- Kubernetes Fundamentals:
1011
- Launching Pods: "5-vote-deploying_pods.md"
1112
- Making application highly available: "replication.md"
@@ -15,8 +16,8 @@ pages:
1516
- Managing Configurations and Secrets: "9-vote-configmaps_and_secrets.md"
1617
- Making Data Persist: "vote-persistent-volumes.md"
1718
- Advanced Kubernetes:
18-
- Kubespray lab setup with Vagrant: "kubespray-prereqs.md"
19-
- Production grade setup with Kubespray: "cluster_setup_kubespray.md"
19+
- Kubespray HA lab setup with Vagrant: "kubespray-prereqs.md"
20+
- HA setup with Kubespray: "cluster_setup_kubespray.md"
2021
- Authentication and Authorization (RBAC): "configuring_authentication_and_authorization.md"
2122
- Advanced Pod Scheduling: "advanced_pod_scheduling.md"
2223
- Pod Resource and Security Specs: "pod-adv-specs.md"

0 commit comments

Comments
 (0)