You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Create Namespace and Add Resource](#creating-namespace-&-adding-resource)
64
65
-[Context](#context)
65
-
-[Config](#config)
66
66
1.[**Cheat sheet**](#cheat-sheet)
67
-
1.**Next steps**
67
+
1.[**Next steps**](#next-steps)
68
68
69
69
70
70
@@ -976,3 +976,109 @@ spec:
976
976
```
977
977
Quickly apply it with `kubectl apply -f appserver-spec.yml`
978
978
979
+
980
+
## Understanding Advance Kubernetes Resources
981
+
982
+
### Namespace
983
+
Namespace are software level cluster virtualization over same physical k8s cluster.
984
+
```bash
985
+
root@vagrant:/home/vagrant# kubectl get ns
986
+
NAME STATUS AGE
987
+
default Active 19d
988
+
kube-node-lease Active 19d
989
+
kube-public Active 19d
990
+
kube-system Active 19d
991
+
```
992
+
993
+
Kubernetes starts with 4 namespaces:
994
+
1. **default**: The default namespace for objects with no other namespace.
995
+
2. **kube-system**: The namespace for objects created by the Kubernetes system.
996
+
3. **kube-public**: This namespace is created automatically and is readable by all users (including those not **authenticated**). This namespace is mostly reserved forcluster usage,incase that some resources should be visible and readable publicly throughout the whole cluster. The public aspect of this namespace is only a convention, not a requirement.
997
+
4. **kube-node-lease**: This namespace for the lease objects associated with each node which improves the performance of the node heartbeats as the cluster scales.
998
+
999
+
Get Pods from specific namespace
1000
+
``kubectl get pods --namespace=default`` OR `kubectl get pods -n default`
1001
+
```bash
1002
+
root@vagrant:/home/vagrant# kubectl get pods --namespace=kube-system
1003
+
NAME READY STATUS RESTARTS AGE
1004
+
coredns-f9fd979d6-g9wxg 1/1 Running 5 19d
1005
+
coredns-f9fd979d6-zrdvs 1/1 Running 5 19d
1006
+
etcd-vagrant 1/1 Running 5 19d
1007
+
kube-apiserver-vagrant 1/1 Running 5 19d
1008
+
kube-controller-manager-vagrant 1/1 Running 7 19d
1009
+
kube-flannel-ds-64l2p 1/1 Running 6 19d
1010
+
kube-proxy-4j4kw 1/1 Running 5 19d
1011
+
kube-scheduler-vagrant 1/1 Running 7 19d
1012
+
```
1013
+
1014
+
#### Creating Namespace & Adding resource
1015
+
- Create namespace :`kubectl create namespace qa`
1016
+
- Once the namespace is created, just add the metadata field :`namespace: qa`, [File](files/pod-qa.yml)
1017
+
```diff
1018
+
apiVersion: v1
1019
+
kind: Pod
1020
+
metadata:
1021
+
name: nginx
1022
+
++ namespace: qa
1023
+
spec:
1024
+
containers:
1025
+
- name: nginx
1026
+
image: nginx
1027
+
```
1028
+
- Most Kubernetes resources (e.g. pods, services, replication controllers, and others) are in some namespaces. However namespace resources are not themselves in a namespace. And low-level resources, such as nodes and persistentVolumes, are not in any namespace.
1029
+
- To see the list of resource not in namespace : `kubectl api-resources --namespaced=false`
1030
+
1031
+
### Context
1032
+
- Is a tuple of **cluster**, **user**, **namespace**. This is useful when you connect to multiple clusters from one control plane.
1033
+
- Get the current context: `kubectl config get-contexts`
- I plan to write a simple cheat sheet covering the commands in this repo. But for now Try : [k8s-official-cheat-sheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)
0 commit comments