-
Notifications
You must be signed in to change notification settings - Fork 29
Kubernetes Controllers
Syed Sayem edited this page Jan 5, 2020
·
3 revisions
- Lets deploy some pod with replication controller using yml file
Create a rs-definition.yml
file
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-replicaset
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-controller
image: nginx
replicas: 3
selector:
matchLabels:
type: front-end
Deploy using following command
kubectl create -f rs-definition.yml
- Get list of replication controller
kubectl get replicationset
- Get list of Pods
kuberctl get pods
- You can increase the number of pods by updating the yml definition file then running:
kubectl replace -f rs-definition.yml
- You can also increase the number of pods by using scale command:
kubectl scale -replicas=6 -f rs-definition.yml
- Delete replication set using:
kubectl delete replication myapp-rs
A Deployment provides declarative updates for Pods and ReplicaSets.
You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments.
Create a deployment-definition.yml
file
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container-pod
image: nginx
- Lets deploy some pod with deployment using yml file
kubectl create -f deployment-definition.yml
- Get list of replication controller
kubectl get deployments
- Get list of Pods
kuberctl get pods