We are going to install and run Kubernetes on local environment.
There are few options to run kubernetes on local like minikube, docker kubernetes and so on. We will follow the docker kubernetes installation.
We should go to Docker Settings
Docker support of Kubernetes
Go to Docker Settings
Kubernetes section
Enable Kubernetes
Declarative vs Imperative
We are going to talk about Declarative vs Imperative.
There are two basic ways to deploy to Kubernetes: imperatively, which is working on CLI with kubectl commands, or declaratively, by writing manifests and using kubectl apply.
Kubernetes able to run both Declarative and Imperative way.
Imperative Configuration
The shortest way to deploy to Kubernetes is to use the kubectl run command.
It said that run myapp with some image with 2 replicas, now!
kubectl run myapp — image myrepo:mytag — replicas 2
Declarative Configuration
The power of Kubernetes is in its declarative API and controllers.
You can just tell Kubernetes what you want, and it will know what to do.
kubectl apply –f app.yaml
You’ll just use kubectl apply and YAML (or JSON) manifests of the state to be saved by Kubernetes in etcd.
Impritive — Declarative
Impritive Commands
kubectl run [container_name] — image=[image_name]
kubectl port-forward [pod] [ports]
kubectl create [resource]
kubectl apply [resource] — create or modify resources
So we will start with Imperative way of kubernetes commands. After that show how we can work with yaml files.