-
Hər container bir podun içinde olur. Daha doğrusu podun içinde hem o container hem de onun helper containerleri olur.
-
Bir nodeda birden çox pod ola biler
-
To create a pod with name nginx using image nginx:
kubectl run nginx --image=nginx
-
Yaml faylda, list ve dictionary nedir ve nece yaradılmalıdır ?
Example:
Employee: Name: Jacob Sex: Male Age: 30 Title: Systems Engineer Projects: - Automation - Support Payslips: - Month: June Wage: 4000 - Month: July Wage: 4500 - Month: August Wage: 4000
-
What are the fields that we must have in all our config files ?
- apiVersion: version of the kubernetes api you are using
- kind: Pod or Service etc.
- metadata: info about the object
- spec: add the container informations here
example pod config:
apiVersion: v1 kind: Pod metadata: name: myapp-pod labels: app: myapp type: front-end spec: containers: - name: nginx-container image: nginx
-
To create the pod using the config files:
kubectl create -f pod_config.yml
-
To see the list of pods available:
kubectl get pods
-
Example Pod config file:
apiVersion: v1 kind: Pod metadata: name: nginx labels: app: nginx tier: frontend spec: containers: - name: nginx image: nginx
-
kubectl describe pod nginx # will describe the pod nginx
-
To add an environment variable to a container:
apiVersion: v1
kind: Pod
metadata:
name: postgres
labels:
tier: db-tier
spec:
containers:
- name: postgres
image: postgres
env:
- name: POSTGRES_PASSWORD
value: mysecretpassword
-
What is ReplicationController ?
- Used to create replicas of the pos in case something happens to the pod
example config file:
apiVersion: v1 kind: ReplicationController metadata: name: myapp-rc labels: app: myapp type: front-end spec: template: metadata: name: postgres labels: app: nginx spec: containers: - name: nginx-container image: nginx replicas: 3
-
To create replicas just type:
kubectl create -f config.yml
-
To replace or update replica-set:
kubectl replace -f replicatt-definition.yaml
kubectl scale replicaset myapp-replicaset --replicas=6
kubectl edit replica-set new-replica-set # name of the replica set
-
Example Replica-set config file:
apiVersion: apps/v1 kind: ReplicaSet metadata: name: frontend labels: app: mywebsite tier: frontend spec: replicas: 4 template: metadata: name: myapp-pod labels: app: myapp spec: containers: - name: nginx image: nginx selector: matchLabels: app: myapp
-
To return the replicasets:
kubectl get replicaset
-
Deployment:
- When you create a deployment or in the future update a deployment, a new rollout is triggered and a new deployment revision is created named revision-2
To see the status of your rollout:
kubectl rollout status deployment/myapp-deployment
To see the rollout history:
kubectl rollout history deployment/myapp-deployment
If you made a mistake in deployment and want to rollback:
kubectl rollout undo deployment/myapp-deployment
-
A deployment config with Recreate strategy:
apiVersion: apps/v1 kind: Deployment metadata: name: frontend labels: app: mywebsite tier: frontend spec: strategy: type: Recreate replicas: 4 template: metadata: name: myapp-pod labels: app: myapp spec: containers: - name: flaskapp image: kodekloud/webapp-color:v2 selector: matchLabels: app: myapp
-
Kubernetes Networking:
In Kubernetes, each node has an IP address.
Inside the nod, there is an internal network and each pod has its own internal IP adress.
-
Kubernetes Services:
- They are objects just like Deployment, Replicaset etc.. Are used to connect port to a pod.
There are 3 types of Services:
- NodePort --> service makes an internal pod accessable on a port on the nod
- ClusterIp --> service creates a virtual IP inside the cluster to enable connection between different servers
- LoadBalancer --> Distribute load accros the different web servers
NodePort config (definition) file:
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: NodePort
ports:
targetPort: 80
port: 80
nodePort: 30008
selector:
app: myapp
type: front-end
To create the service:
kubectl create -f service-definition.yml
To show the created services:
kubectl get services