CKA Study Flashcards
Command: Apply configuration changes to a resource
kubectl apply -f FILENAME
Command: Access a web server via a NodePort
curl http://<Node>:<NodePort>
ie: http://198.168.1.2:30008</NodePort></Node>
Command: Create a resource
kubectl create -f FILENAME
Command: Creating a file from a Deployment
kubectl create deployment –image=nginx nginx –dry-run=client -o yaml > nginx-deployment.yaml
Command: Edit and update the definition of a resource
kubectl edit (-f FILENAME | TYPE NAME)
Command: Get documentation for a resource type
kubectl explain RESOURCE-TYPE
Command: Replace a resource
kubectl replace –force -f FILENAME
Command: Update the size of the specified replication controller
kubectl scale -f FILENAME
Command: Change the ETCD API version for commands
If you get the message, “No help topic for …”
export ETCDCTL_API=3 (default is 2)
Command: Execute a command against an resource
kubectl exec etcd-master -n kube-system etcdctl get / –prefix - keys-only
Command: List Pods
kubectl get pods
Command: Display the detailed state of a Pod
kubectl describe pod <Pod> -n=NAMESPACE</Pod>
Command: View a running resource and its effective options
ps -aux | grep <Process-Name></Process-Name>
If a specific Controller doesn’t seem to work or exist
Look at the Kube-Controller-Manager options
Kubeadm: /etc/kubernetes/manifests/kube-controller-manager.yaml
Non-Kubeadm: /etc/systemd/system/kube-controller-manager.service
Location: Where is the Pod Definition file located
Kubeadm: /etc/kubernetes/manifests/kube-apiserver.yaml
Non-Kubeadm: /etc/systemd/system/kube-apiserver.service
Object: ETCD-Master
Key/Value data store
Runs on Port 2379
Can be accessed via a browser at https://<IP>:2379</IP>
Set Value: ./etcdctl set key1 value1
Get Value: ./etcdctl set key1
Object: Kube-APIServer
Authenticate User
Validate Request
Retrieve Data
Update ETCD
Used by Kube-Scheduler-Master and Kubelet
Object: Kube-Proxy
Runs on each Node in the Cluster
Look for new Services
Creates an new Rule on each Node to forward traffic to those Services
Object: Kube-Scheduler
Decides which Pod goes on which Node
Kubeadm: /etc/kubernetes/manifests/kube-scheduler.yaml
Non-Kubeadm: /etc/systemd/system/kube-scheduler.service
Object: Kubelet
Registers Node on the K8S cluster
Creates Pods
Monitors Nodes and Pods
Configuration located at /var/lib/kubelet/config.yaml
Object: Master Node
ETCD: Information on the cluster
Kube-Scheduler: Schedule applications or containers
Kube-Controller-Manager: Takes care of all controllers
Kube-APIServer: Orchestrating operations on the cluster
Object: Kube-Controller-Manager
Monitors services and brings them to the desired state
Object: Node-Controller
Monitor Nodes and keeps Pods running
Object: Namespace Kube-System
Namespace for system resources
Object: Namespace Kube-Public
Namespace for shared resources
Object: ResourceQuota
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-quota
spec:
hard:
pods: “10”
requests.cpu: “4”
requests.memory: 5Gi
limits.cpu: “10”
limits.memory: 10Gi
Object: ClusterIP Service
Creates a virtual IP to enable communication between services and pods, in the cluster
Object: NodePort Service
Listens to a port and forwards requests on that port to another port, across the cluster
- the Port is required and must be between 30000 and 32676
- if the TargetPort is not specified, it will be the same value as Port
- if the NodePort is not specified, it will be automatically assigned
NodePort services also externally exposes the IP Address
Object: LoadBalancer Service
Provisions a Load Balancer for applications
Object: Pods
A single instance of an Application
Helper Containers, supporting the Application, can be in the same Pod
There are many Pods in a Node
Object: Replication-Controller
Manages the Replicate Sets
- Pods per Set
- High Availability and Resiliency
Object: Worker Node
Container Engine: Docker (other engines are available)
Kubelet: Listens to Kube-API-Server and carries out instructions
Kube-Proxy: communication between nodes
YAML: Service NodePort
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: NodePort
ports:
- targetPort: 80
port: 80
nodePort: 30008
selector:
app: myapp
type: frontend
In the Selector, app and type are copied from the Pod’s Labels section
YAML: Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment
labels:
app: myapp
tier: frontend
spec:
template:
metadata:
name: myapp-pod
labels:
app: myapp
tier: frontend
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
selector:
matchLabels:
type: frontend
YAML: Namespace
apiVersion: v1
kind: Namespace
metadata:
name: my-namespace
YAML: Pod
apiVersion: v1
kind: Pod
metadata:
name: my-nginx
labels:
app: nginx
tier: frontend
spec:
containers:
- name: my-nginx
image: nginx
YAML: ReplicaSet
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-replicaset
labels: // these labels are for the ReplicaSet
app: myapp
tier: frontend
spec:
template:
metadata:
name: myapp-pod
labels: // these labels are for filtering the specific Pods
app: myapp
tier: frontend
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
selector:
matchLabels: // these matchLabels must match the Pod filtering labels
type: frontend
YAML: ReplicationController
apiVersion: v1
kind: ReplicationController
metadata:
name: myapp-rc
labels:
app: myapp
tier: frontend
spec:
template:
metadata:
name: myapp-pod
labels:
app: myapp
tier: frontend
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
YAML: Service ClusterIP
apiVersion: v1
kind: Service
metadata:
name: backend
spec:
type: ClusterIP
ports:
- targetPort: 80
port: 80
selector:
app: myapp
type: backend
In the Selector, app and type are copied from the Pod’s Labels section
YAML: Service LoadBalancer
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: LoadBalancer
ports:
- targetPort: 80
port: 80
nodePort: 30008
Command: Create a Pod from the command line
kubectl run nginx –image=nginx –port=8080
Command: Create a Service to expose a Deployment or Pod
kubectl expose deployment nginx –port 80 –name nginx-service
kubectl expose pod redis –port 80 –name redis-service
Command: Update an Image on a Deployment
kubectl set image deployment nginx nginx=nginx:1.18