Kubernetes 04/14/2021
Todays topic:- jobs, cronjob, etcd
Jobs
----
Launch your minikube
> minukube start
Container is equal to process
image -> launch -> container -> process
life of a container is a life of process
process killed, container is killed.
When you launch a container, the life of conainer is infinite.
unless you delete it. Any pod we launch is a server - webserver.
- These server never stop.
- They keep on running
- If they fail, by default we have policy - always policy
There are multiple policies and always is one of them.
restart policy on POD.
batch processing
> kc get job
deployment also launch pod and if they stop, they start automatically.
if job completed, they don't relaunch.
we want some job run on some interval.
We can get it schdule it using crontjob
> kc get cronjob
if you have a work, to run particular job say batch job, kubernetes has a resource: job, crontab
# echo $SHELL
bash
lets take a look on a simple eg,
$ for i in 1 2 3 4 5 6 ; do echo $i; done
Lets create a deployment
> kc create deploy myd --image=centos:7 -o yaml >j.yaml
[root@master ~]# kc create deploy myd --image=centos:7 -o yaml >j.yaml
[root@master ~]# cat j.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: myd
name: myd
namespace: default
spec:
replicas: 3
selector:
matchLabels:
app: myd
template:
metadata:
labels:
app: myd
spec:
containers:
- image: centos:7
imagePullPolicy: IfNotPresent
name: centos
#- "/bin/bash"
- "/bin/sh"
- "-c"
- "for i in 1 2 3 4 5 6; do echo $i; done"
restartPolicy: Always #(or Never)
[root@master ~]#
> kc apply j.yaml
> kc get pods
[root@master ~]# cat j.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: myd
name: myd
namespace: default
spec:
completitions: 6
replicas: 3
selector:
matchLabels:
app: myd
template:
metadata:
labels:
app: myd
spec:
containers:
- image: centos:7
imagePullPolicy: IfNotPresent
name: centos
#- "/bin/bash"
- "/bin/sh"
- "-c"
- "for i in 1 2 3 4 5 6; do echo $i; done"
restartPolicy: Always #(or Never)
[root@master ~]#
[root@master ~]# cat j.yaml
apiVersion: apps/v1
kind: Job
metadata:
labels:
app: myd
name: myd
namespace: default
spec:
completitions: 6
parallellism: 2
replicas: 3
selector:
matchLabels:
app: myd
template:
metadata:
labels:
app: myd
spec:
containers:
- image: centos:7
name: centos
command: [ "expr", "2", "+", "4" ]
restartPolicy: Always #(or Never)
[root@master ~]#
> kc apply j.yaml
> kc get po
> kc delete job --all
cronjob
[root@master ~]# cat j.yaml
apiVersion: apps/v1
kind: Cronjob
metadata:
labels:
app: myd
name: myd
namespace: default
spec:
schedule: "*/2 * * * *" # every 2 min
jobTemplate:
spec:
completitions: 6 # 6 total
parallellism: 2 # 2 in parallel
replicas: 3
selector:
matchLabels:
app: myd
template:
metadata:
labels:
app: myd
spec:
containers:
- image: centos:7
name: centos
command: [ "expr", "2", "+", "4" ]
restartPolicy: Always #(or Never)
[root@master ~]#
>kc deletete job --all
> kc apply -f j.yaml
> ck get pods
Thursday, April 15, 2021
Day39 - Kubernetes - jobs, cronjobs, etcd
Subscribe to:
Post Comments (Atom)
Git branch show detached HEAD
Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03) 00 2. Run re-set hard $ git reset --hard 3. ...
-
snmpconfig command allow you to managge snmpv1/v3 agent configuration on SAN switch. Event trap level is mapped with event severity level....
-
Firmware upgrade on HPE SuperDom Flex 280 - prerequisites tasks a. Set up repo b. Upload firmware to your webserver 1. For foundation so...
-
Disabling the Telnet protocol on Brocade SAN switches By default, telnet is enabled on Brocade SAN switches. As part of security hardening o...
No comments:
Post a Comment