Operation modes of kubectl
Imperative
- I would tell kubectl what action has to be taken
kubectl run tomcat --image=tomcat:8
Declarative
- Maintaining declared state.
- Declarative state is mentioned in some file.
- To describe Declarative State in k8s we use YAML files.
- Lets assume you have yaml file test.yml.
kubctl apply -f test.yml
kubectl delete -f test.yml
Kubernetes APIs
- All capabilities of K8s are exposed as REST APIs
- To execute APIs
- kubectl
- Client Libraries
- APIs are changing every day, then how should i use in my Production Systems.
API Versions
- Are of three types
- Alpha: inside api version if you see alpha
- Beta: inside api version if you see beta
- Stable: inside api version if you see vX here X is a integer
API groups
Refer here for more info
Resources and Objects
- Resources are all the possibilities in K8s
- Objects are what you are creating
Commands
kubectl api-versions
Resource Category Workload
-
Pod:
- smallest unit of creation in k8s
- Pod has
- Container(s)
- Storage
- IP Address
-
Controller
Kubernetes Objects
- Object has two nested groups
-
Object Spec:
- input
- Desired state
-
Object Status:
- output
- Actual State
-
- Syntax:
apiVersion: <apiversion>
kind: <type>
metadata:
key1: <value1>
spec: <objectspec>