I have a single node OpenSearch cluster running in k8s
I want to run the OpenSearch pod on a particular node out of 3 nodes.
The deployment type is stateful set
I am using default k8s scheduler
I am trying to add nodeselector in my stateful yaml in various ways but it is failing.
@abhyankar Your link refers to OpenSearch helm charts. I assume that your cluster is deployed with official helm charts. If that’s true, then I don’t understand why you bother to modify statefulset.yml.
You can provide nodeselector value using values.yml file (line 396 - .Values.nodeSelector)
I am not using helm chart but I am reading the yaml as reference to use nodeselector.
I tried to use the content from line number 396 from values.yml and tried to put it in spec in my statefulset.yml but when I am deploying it, I am getting error like the 1 I mentioned above thanks.
If I apply this code, the 3 pods are getting deployed only on 2 nodes.
I do not have any taints as this is a non production environment.
The env is hosted that means none of the node from the list is a master node.
I tried adding combination of node affinity by [indentation is disturbed after pasting here] =
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
But behavior is same.
1 pod is not able to get scheduled on 1 specific node.
Same result for pod affinity.
I tired to run sample nginx stateful set and each pod is getting on every node.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: example-statefulset
labels:
app: example
spec:
serviceName: example
replicas: 3
selector:
matchLabels:
app: example
template:
metadata:
labels:
app: example
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
containers:
- name: example-container
image: nginx:latest
ports:
- containerPort: 80
volumeClaimTemplates:
- kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: example
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
@abhyankar Just to be clear. This issue is not related to OpenSearch software. You’re having an issue with the Kubernetes pod placement.
However, based on your error you’ve placed nodeSelector in the incorrect spec. You must place it under the .spec.template.spec.
Readiness probe failed: sh: line 2: local: can only be used in a function sh: line 3: local: can only be used in a function sh: -c: line 15: syntax error near unexpected token }’ sh: -c: line 15: }'