I am running an application as a StatefulSet with 2 Pods. I recently discovered an issue which requires clearing some contents on disk and restarting the application.
I would like to minimize customer impact by having atleast one Pod running.
This is fairly trivial for pod-1
as I can scale it down and do the needful and scale it backup. However StatefulSets will not run pod-1
if pod-0
is not running therefore I can't just take pod-0
out of the Service.
I am aware that there is perhaps a way to relabel the Pod to take pod-0
out of the Service. This unfortunately is not an option as it will spin up a new pod-0
(from what I understand).
Is there method to expose a select Pod via the Service or to remove it from the Service Endpoints and re-add it?
Example Spec File
spec:
podManagementPolicy: OrderedReady
replicas: 2
revisionHistoryLimit: 10
selector:
matchLabels:
app: myapp
serviceName: myapp-headless
template:
metadata:
creationTimestamp: null
labels:
app: myapp
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: app
operator: NotIn
values:
- confluence
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- myapp
topologyKey: kubernetes.io/hostname
containers:
- env:
- name: JVM_MINIMUM_MEMORY
value: 4g
- name: JVM_MAXIMUM_MEMORY
value: 4g
- name: CATALINA_CONNECTOR_PROXYNAME
value: myapp.dev.example.com
- name: CATALINA_CONNECTOR_PROXYPORT
value: "443"
- name: CATALINA_CONNECTOR_SCHEME
value: https
- name: CATALINA_CONNECTOR_SECURE
value: "true"
- name: CLUSTER
value: "true"
- name: CLUSTER_DOMAIN
value: myapp-headless.proteus.svc.cluster.local
- name: CROWD_SSO
value: "false"
- name: CROWD_APP_NAME
value: myapp
- name: CROWD_APP_PASSWORD
value: xxx
- name: CROWD_BASEURL
value: https://crowd.dev.example.com
image: xxx
imagePullPolicy: IfNotPresent
name: myapp
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 40001
name: ehcache
protocol: TCP
resources:
limits:
memory: 8Gi
requests:
memory: 4Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/vendor/application-data/myapp-home
name: home
- mountPath: /var/vendor/application-data/myapp-home/shared
name: shared
- mountPath: /var/vendor/application-data/myapp-home/dbconfig.xml
name: myapp-db-config
subPath: dbconfig.xml
- mountPath: /opt/vendor/myapp/logs
name: tomcat-logs
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: ecr
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
fsGroup: 2
runAsUser: 2
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: myapp-dbconfig-cm
name: myapp-db-config
- name: shared
persistentVolumeClaim:
claimName: myapp-shared
- emptyDir: {}
name: tomcat-logs
updateStrategy:
type: OnDelete
volumeClaimTemplates:
- metadata:
creationTimestamp: null
name: home
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: myapp-home-volume