K8S, Namespace Command
*** K8S, Namespace Command
kube-system
Default
kube-public
mysql.connect("db-service.dev.svc.cluster.local")
db-service: Service Name
dev: Namespace
svc: Service
cluster.local: domain
kubectl get pods
kubectl get pods --namespace=kube-system
kubectl create -f pod-definition.yml
kubectl create -f pod-definition.yml --namespace=dev
----------------------------------------------------------------------------------------
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
namespace: dev
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
namespace-dev.yml
apiVersion: v1
kind: Namespac
metadata:
name: dev
kubectl create -f namespace-dev.yml
kubectl create namespace dev
----------------------------------------------------------------------------------------
kubectl get pods --namespace=dev
kubectl get pods
kubectl get pods --namespace=prod
kubectl config set-context $(kubectl config current-context) --namespace=dev
kubectl get pods
kubectl get pods --namespace=default
kubectl get pods --namespace=prod
kubectl config set-context $(kubectl config current-context) --namespace=prod
kubectl get pods
kubectl get pods --namespace=default
kubectl get pods --namespace=dev
kubectl get --all-namespaces
----------------------------------------------------------------------------------------
*** Resource Quota
compute-quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-quota
namespace: dev
spec:
hard:
pods: "10"
requests.cpu: "4"
requests.memory: 5Gi
limits.cpu: "10"
limits.memory: 10Gi
----------------------------------------------------------------------------------------
kubectl create -f compute-quota.yaml
--------------------------------------------------------------------------------------------------
kubectl get namespaces
kubectl get ns
kubectl get pods --namespace=research
kubectl get pods --n=research
kubectl run redis --images=redis -n=finance
kubectl get pods --n=finance
kubectl get ns
kubectl get pods --all-namespaces
kubectl get pods -A
kubectl get pods -n=marketing
kubectl get svc -n=marketing
kubectl get svc -n=dev