Reindex Jira Data Center without downtime on Kubernetes


There are two ways to reindex Jira Data Center without downtime on Kubernetes. My Jira cluster runs a statefulSet in kubernetes. The configuration details:

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: jira
spec:
serviceName: jira
replicas: 3
selector:
matchLabels:
app: jira
template:
metadata:
labels:
app: jira
spec:
containers:
name: jira
image: atlassian/jira-software:8.5
readinessProbe:
httpGet:
path: /status
port: 8080
initialDelaySeconds: 120
periodSeconds: 10
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 600
periodSeconds: 10
envFrom:
configMapRef:
name: jira-config
ports:
containerPort: 8080
name: web
volumeMounts:
name: local-home
mountPath: /var/atlassian/application-data/jira
name: jira-share-pv
mountPath: /var/atlassian/application-data/jira/shared-home
volumes:
name: jira-share-pv
persistentVolumeClaim:
claimName: jira-share-pvc
volumeClaimTemplates:
metadata:
name: local-home
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 5Gi

DON’T use the following methods if you have livenessProbe to monitor the /status. As your pod may get killed when it is doing the re-indexing. You should monitor / for livenessProbe instead. Why? Check this out: Configured livenessProbe and readinessProbe for Jira pod in Kubernetes.

Method one: Temporarily remove one pod from the Jira service, so there will be no traffics directed to it. It is safer, but requires a bit more steps.

Kubernete service use label to select the backend pod. So the idea is to temporarily change the label of one pod.

# Check all pods that servers Jira service traffics
$ kubectl get pods -l app=jira
NAME     READY   STATUS    RESTARTS   AGE
jira-0   1/1     Running   0          155m
jira-1   1/1     Running   0          152m
jira-2   1/1     Running   0          150m

# Remove pod jira-2 by changing the label
$ kubectl label --overwrite pods jira-2 app=jira-index
pod/jira-2 labeled

# Confirm jira-2 has been removed
$ kubectl get pods -l app=jira
NAME     READY   STATUS    RESTARTS   AGE
jira-0   1/1     Running   0          159m
jira-1   1/1     Running   0          157m

# Forward remote pod port 8080 to local 9999
$ kubectl port-forward jira-2 9999:8080

# Go to http://localhost:9999, then run the Jira forground index. Once it is completed, add the pod back, so it can replicate the latest index file to other nodes.
$ kubectl label --overwrite pods jira-2 app=jira

Method two: Utilize the readinessProbe.

When Jira is doing the foreground reindexing, the /status return 503. So if you have the readnessProbe configured, then it will detect that the pod (the one that is doing reindexing) is not ready so no traffics will be directed to it. Well, user may hit this pod during the check gap. It depends on how often the readiness probe runs.

        readinessProbe:
          httpGet:
            path: /status
            port: 8080
          initialDelaySeconds: 120
          periodSeconds: 10

Reference: https://confluence.atlassian.com/jirakb/reindex-jira-data-center-without-downtime-757467576.html

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s