Can you describe the events of the pod why it’s not running?
kubectl describe pod pod-name
Pod should be schedule on master node but i can see it’s trying to schedule on node01 ? as per question.
how to schedule it on masternode??
Whatever i said apply it, it will be up and run but schedule this pod on master not in node01
I am trying what all you said , thanks for your support and quick reply
What is the name of master node?
To see do “kubectl get nodes”
kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 6h13m v1.16.0
node01 Ready 6h12m v1.16.0
Add also this to schedule on master, “nodeName: master-name” whatever it is, Under the Pod spec in your deployment manifest file.
spec:
nodeName: master-name
To validate , Deployment Pods deployed on master node or somewhere run the following command: -
kubectl get pods -owide
Collect all the data and give it a try again. If any issue let me know.
You have to write under pod template not deployment.
ok , thank you so much for all your guidance
Welcome…
@Tej-Singh-Rana We are writing here deployment template only right?
How to write POD template inside deployment?
Below is my redis-deployment-yml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-deployment
spec:
selector:
matchLabels:
app: redis
role: master
nodename: master
replicas: 1
template:
metadata:
labels:
app: redis
role: master
spec:
containers:
- name: redis-container
image: redis:alpine
resources:
requests:
cpu: 1
ports:
- containerPort: 6379
volumeMounts:
- mountPath: /redis-master-data
name: data
- mountPath: /redis-master
name: config
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: redis-config
items:
- key: redis-config
path: redis.conf
Can you please tell me, how to tell this deployment to run on Master node?
Hello, balu.networks7
You need to define nodeName field as you did but in the wrong place. nodeName field comes under the template.spec.
You volumes configMap not looks good. You need to define only configmap name.
@Tej-Singh-Rana Thanks for your immediate response.
Now I tried with below template:
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-deployment
spec:
nodename: master
selector:
matchLabels:
app: redis
role: master
replicas: 1
template:
metadata:
labels:
app: redis
role: master
spec:
containers:
- name: redis-container
image: redis:alpine
resources:
requests:
cpu: 1
ports:
- containerPort: 6379
volumeMounts:
- mountPath: /redis-master-data
name: data
- mountPath: /redis-master
name: config
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: redis-config
I am getting below error:
thor@jump_host /$ kubectl create configmap redis-config --from-literal=maxmemory=2mb
configmap/redis-config created
thor@jump_host /$ kubectl apply -f redis-deployment.ymlerror: error validating "redis-deployment.yml": error validating data: ValidationError(Deployment.spec): unknown field "nodename" in io.k8s.api.apps.v1.DeploymentSpec; if you choose to ignore these errors, turn validation off with --validate=false
thor@jump_host /$
Can you please give some idea to fix this.
I am seeing everywhere its mentioned that, node name should come under POD template, like:
apiVersion: v1
kind: Pod
spec:
nodeName: <value>
How to mention this under Deployment template?
I think i wrote template then spec that means under pod spec.
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-deployment
spec:
< deployment specification field>
replicas: 1
template:
metadata:
labels:
spec:
<pod specification fields>
under template whatever you will add counted in the pod spec.
Sure Thanks @Tej-Singh-Rana
And also In question its mentioned that:
It should mount exactly
2 volumes
How to specify this in our manifest file?
You already did under the volumes section. Need a minor changes in the configMap volume.