Showing posts with label Port. Show all posts
Showing posts with label Port. Show all posts

Saturday, 5 September 2020

Kubernetes Objects

aws s3 ls s3://sandipp-demo --recursive | awk '{$1=$2=$3=""; print $0}' | sed 's/^[ \t]*//'

Create Pod kubectl run nginx --generator=run-pod/v1 --image=nginx
Create in particular namespace kubectl run nginx --generator=run-pod/v1 --image=nginx -n NAMEPSPACE
Dry run,print object without creating it kubectl run POD_NAME --generator=run-pod/v1 --image=nginx --dry-run -o yaml
Create and write its spec to file kubectl run POD_NAME --image=nginx --restart=Never --dry-run -o yaml > pod.yaml
Create from File kubectl create -f pod.yaml
Create from File in particular namespace kubectl create -f pod.yaml -n NAMEPSPACE

List Pods kubectl get po or kubectl get pod or kubectl get pods
List pods in all namespaces kubectl get pods --all-namespaces or kubectl get pods -A
List/Get Particular Pod kubectl get po #POD_NAME# or kubectl get pod #POD_NAME# or kubectl get pods #POD_NAME#
List pods with more information kubectl get pods -owide
List pod in Json output format kubectl get pods -o json
List pod in YAML output format kubectl get pods -o yaml
List pods with more information in custom columns kubectl get pod POD_NAME -o custom columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image

Delete Pods kubectl delete pod #POD_NAME# or kubectl delete -f pod.yaml or kubectl delete pod/#POD_NAME#
Delete pod in particular namespace kubectl delete pod #POD_NAME# -n #NAMEPSPACE_NAME#
Delete pod forcefully kubectl delete pod #POD_NAME# --grace-period=0 --force

Check Pod Logs kubectl logs #POD_NAME#
Check Pod Logs (multi-container case) kubectl logs #POD_NAME# -c #CONTAINER_NAME#
Tail Pod Logs kubectl logs -f #POD_NAME#
Tail Pod Logs (multi-container case) kubectl logs -f #POD_NAME# -c #CONTAINER_NAME#

Verbose Debug information/describe pod kubectl describe pod #POD_NAME#
Watch pod kubectl get pod POD_NAME --watch

Verbose Debug information/describe pod kubectl patch pod #POD_NAME# -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname"}]}}'

Exec to pod kubectl exec -it #POD_NAME# bash
Run command in existing pod kubectl exec -it #POD_NAME# -- ls /
Run command in existing pod (multi-container case) kubectl exec -it #POD_NAME# -c #CONTAINER_NAME# -- ls /

Create deployment kubectl create deployment #DEPLOYMENT_NAME# --image=busybox
Create deployment in particular namespace kubectl create deployment #DEPLOYMENT_NAME# --image=busybox -n NAMEPSPACE
Run deployment with 2 Replicas kubectl run #DEPLOYMENT_NAME# --image=nginx --replicas=2 --port=80
Run deployment and expose it kubectl run #DEPLOYMENT_NAME# --image=nginx --port=80 --expose
Create deployment from File kubectl create -f deployment.yaml
Create deployment from File in particular namespace kubectl create -f deployment.yaml -n #NAMEPSPACE_NAME#

List deployments kubectl get deploy or kubectl get deployment or kubectl get deployments
List deployments in all namespaces kubectl get deploy --all-namespaces or kubectl get deploy -A
List deployments in particular namespace kubectl get deploy -n #NAMESPACE_NAME#
List/Get Particular deployment kubectl get deploy #DEPLOY_NAME# or kubectl get deployment #DEPLOY_NAME# or kubectl get deployments #DEPLOY_NAME#
List deployments with more information kubectl get deployment -owide

Delete deployment kubectl delete deploy #DEPLOYMENT_NAME# or kubectl delete -f deployment.yaml or kubectl delete deploy/#DEPLOYMENT_NAME#
Delete deployment in particular namespace kubectl delete deployment #DEPLOYMENT_NAME# -n #NAMEPSPACE_NAME#

Verbose Debug information/describe particular Deployment kubectl describe deployment #DEPLOYMENT_NAME#
Decribe All Deployments kubectl describe deployments
Watch Deployment kubectl get deployment #DEPLOYMENT_NAME# --watch

Edit Deployment kubectl edit deployment #DEPLOY_NAME#
Patch/Update Deployment (Update nginx pod image to 1.9.1 instead of 1.7.9) kubectl set image deployment/nginx-deployment ngnix=nginx:1.9.1 --record
Scaliing Deployment kubectl scale deployment/nginx-deployment --replicas=2

Deployment Rollout Status kubectl rollout status deployment/#DEPLOYMENT_MAME#
Deployment Rollout History kubectl rollout history deployment/#DEPLOYMENT_MAME#
Pausing Rollout Deployment kubectl rollout pause deployment/#DEPLOYMENT_MAME#
Resuming Rollout Deployment kubectl rollout resume deployment/#DEPLOYMENT_MAME#
Rollback Deployment to Previous Verion kubectl rollout undo deployment/#DEPLOYMENT_MAME#

Create ReplicaSet kubectl create -f replicaset.yaml

List ReplicaSets kubectl get rs or kubectl get replicaset or kubectl get replicasets
List ReplicaSets in all namespaces kubectl get rs --all-namespaces or kubectl get rs -A
List ReplicaSet with more information kubectl get rs -owide
List Specific ReplicaSet kubectl get rs #REPLICASET_NAME#

Delete ReplicaSet kubectl delete rs #REPLICASET_NAME# or kubectl delete -f replicaset.yaml

Create ClusterIP Service kubectl create service clusterip #SERVICE_NAME# --tcp=5678:8080
Create ClusterIP Service in Headless Mode kubectl create service clusterip #SERVICE_NAME# --clusterip="None"
Create NodePort Service kubectl create service nodeport #SERVICE_NAME# --tcp=5678:8080
Create LoadBalancer Service kubectl create service loadbalancer #SERVICE_NAME# --tcp=5678:8080
Create ExternalName Service kubectl create service externalname #SERVICE_NAME# --extername example.com

List Service kubectl get svc or kubectl get service or kubectl get services
List Specific Service kubectl get svc #SERVICE_NAME#

Delete Service kubectl delete svc #SERVICE_NAME# or kubectl delete -f service.yaml

Verbose Debug information/Describe Service kubectl describe svc #SERVICE_NAME#

Create Namespace kubectl create ns #NAMESPACE_NAME# or kubectl create -f namespace.yaml

List Namespace kubectl get ns or kubectl get namespace or kubectl get namespaces
List Specific Namespace kubectl get ns #NAMESPACE_NAME#

Delete Namespace kubectl delete ns #NAMESPACE_NAME# or kubectl delete -f namespace.yaml

Verbose Debug information/Describe Namespace kubectl describe ns #NAMESPACE_NAME#

Create ServiceAccount kubectl create sa #SERVICE_ACCOUNT_NAME# or kubectl create -f service-account.yaml

List ServiceAccount kubectl get sa or kubectl get serviceaccount or kubectl get serviceaccounts
List Specific ServiceAccount kubectl get sa #SERVICE_ACCOUNT_NAME#

Delete ServiceAccount kubectl delete sa #SERVICE_ACCOUNT_NAME# or kubectl delete -f service-account.yaml

Verbose Debug information/Describe ServiceAccount kubectl describe sa #SERVICE_ACCOUNT_NAME#

List DaemonSets kubectl get ds or kubectl get daemonset or kubectl get daemonsets
List DaemonSets in all namespaces kubectl get ds --all-namespaces or kubectl get ds -A
List DaemonSet with more information kubectl get ds -owide
List Specific DaemonSet kubectl get ds #DAEMONSET_NAME#

Delete DaemonSet kubectl delete ds #DAEMONSET_NAME# or kubectl delete -f daemonset.yaml

Verbose Debug information/Describe DaemonSet kubectl describe ds #DAEMONSET_NAME#

Create Job kubectl create job #JOB_NAME# --image=busybox
Create Job with linux command kubectl create job #JOB_NAME# --image=busybox --date
Create Job from a cronjob named "cronjob-1" kubectl create job #JOB_NAME# --from=cronjob/cronjob-1

List Jobs kubectl get job or kubectl get jobs
List Jobs in all namespaces kubectl get job --all-namespaces or kubectl get job -A
List Jobs with more information kubectl get job -owide
List Specific Job kubectl get job #JOB_NAME#

Delete job kubectl delete job #JOB_NAME# or kubectl delete -f job.yaml

Verbose Debug information/Describe Job kubectl describe job #JOB_NAME#

Create Scheduled CronJob kubectl create cronjob #CRONJOB_NAME# --image=busybox --schedule="*/1 * * * *"

List CronJobs kubectl get cj or kubectl get cronjob or kubectl get cronjobs
List CronJobs in all namespaces kubectl get cj --all-namespaces or kubectl get cj -A
List CronJobs with more information kubectl get cj -owide
List Specific CronJob kubectl get cj #CRONJOB_NAME#

Delete CronJob kubectl delete cj #CRONJOB_NAME# or kubectl delete -f cronjob.yaml

Verbose Debug information/Describe CronJob kubectl describe cj #CRONJOB_NAME#

Kubernetes Cluster (Master and Worker) Nodes Required Ports

 

Master Nodes - Required Ports

Protocol Direction Port Range Purpose Used By
TCP Inbound 6443* Kubernetes API server All
TCP Inbound 2379-2380 etcd server client API kube-apiserver, etcd
TCP Inbound 10250 Kubelet API Self, Control plane
TCP Inbound 10251 kube-scheduler Self
TCP Inbound 10252 kube-controller-manager Self

Worker Nodes - Required Ports

@echo off setlocal enableextensions FOR /F "tokens=* USEBACKQ" %%g IN (`aws service-quotas get-service-quota --service-code iam --quota-code L-94F408A6 --query "Quota.{Value:Value}" --output text`) DO (SET AWS_RESOURCE_QUOTA_VALUE=%%g) ECHO %AWS_RESOURCE_QUOTA_VALUE% IF %AWS_RESOURCE_QUOTA_VALUE%==15.0 ( ECHO "THE REQUEST QUOTA VALUE 15.0" ) ELSE IF %AWS_RESOURCE_QUOTA_VALUE%==10.0 ( ECHO "THE REQUEST QUOTA VALUE 10.0" aws service-quotas request-service-quota-increase --service-code iam --quota-code L-94F408A6 --desired-value 15.0 ) ELSE ( ECHO "THE REQUEST QUOTA VALUE IS NOT 15.0 or 10.0" )
Protocol Direction Port Range Purpose Used By
TCP Inbound 10250 Kubelet API Self, Control plane
TCP Inbound 30000-32767 NodePort Services† All