Fferanet
Wiki menu

Kubernetes

Basic Commands

Get Cluster Information

kubectl cluster-infobash

Get Nodes

kubectl get nodesbash

Get Pods

kubectl get podsbash

Get Services

kubectl get servicesbash

Describe a Pod

kubectl describe pod pod_namebash

Create a Deployment

kubectl create deployment nginx --image=nginxbash

Expose a Deployment

kubectl expose deployment nginx --port=80 --type=NodePortbash

Scale a Deployment

kubectl scale deployment nginx --replicas=3bash

Delete a Deployment

kubectl delete deployment nginxbash

Configuration Files

Deployment Configuration

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.14.2
          ports:
            - containerPort: 80yaml

Service Configuration

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: NodePortyaml