Skip to content

Commit

Permalink
nexus/clusterIP-headlessService (helm#8565)
Browse files Browse the repository at this point in the history
* support for clusterIP services with specific cluster IP or None for headless service.

Signed-off-by: Arvind Gupta <guptaarvindk@gmail.com>

* - added support for statefulsets, while keeping backward compatibility for deploymnet usage.
- fixed issues from previous PR
- bumped up minor version.
Signed-off-by: Arvind Gupta <guptaarvindk@gmail.com>
  • Loading branch information
guptaarvindk authored and k8s-ci-robot committed Oct 26, 2018
1 parent aa15754 commit 49b4a37
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 12 deletions.
2 changes: 1 addition & 1 deletion stable/sonatype-nexus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sonatype-nexus
version: 1.13.0
version: 1.14.0
appVersion: 3.13.0-01
description: Sonatype Nexus is an open source repository manager
keywords:
Expand Down
8 changes: 7 additions & 1 deletion stable/sonatype-nexus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The following table lists the configurable parameters of the Nexus chart and the

| Parameter | Description | Default |
| ------------------------------------------ | ---------------------------------- | ----------------------------------------|
| `statefulset.enabled` | Use statefulset instead of deployment | `false` |
| `replicaCount` | Number of Nexus service replicas | `1` |
| `deploymentStrategy` | Deployment Strategy | `rollingUpdate` |
| `nexus.imageName` | Nexus image | `quay.io/travelaudience/docker-nexus` |
Expand All @@ -71,7 +72,8 @@ The following table lists the configurable parameters of the Nexus chart and the
| `nexus.resources` | Nexus resource requests and limits | `{}` |
| `nexus.dockerPort` | Port to access docker | `5003` |
| `nexus.nexusPort` | Internal port for Nexus service | `8081` |
| `nexus.serviceType` | Service for Nexus | `NodePort` |
| `nexus.service.type` | Service for Nexus |`NodePort` |
| `nexus.service.clusterIp` | Specific cluster IP when service type is cluster IP. Use None for headless service |`nil` |
| `nexus.securityContext` | Security Context (for enabling official image use `fsGroup: 2000`) | `{}` |
| `nexus.labels` | Service labels | `{}` |
| `nexus.podAnnotations` | Pod Annotations | `{}`
Expand Down Expand Up @@ -172,6 +174,10 @@ you can change the `values.yaml` to disable persistence which will use an `empty

> *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."*

You must enable StatefulSet (`statefulset.enabled=true`) for true data persistence. If using Deployment approach, you can not recover data after restart or delete of helm chart. Statefulset will make sure that it picks up the same old volume which was used by the previous life of the nexus pod, helping you recover your data. When enabling statefulset, its required to enable the persistence.


### Recommended settings

As a minimum for running in production, the following settings are advised:
Expand Down
2 changes: 2 additions & 0 deletions stable/sonatype-nexus/templates/backup-pv.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.statefulset.enabled }}
{{- if .Values.nexusBackup.persistence.pdName -}}
apiVersion: v1
kind: PersistentVolume
Expand All @@ -17,3 +18,4 @@ spec:
pdName: {{ .Values.nexusBackup.persistence.pdName }}
fsType: {{ .Values.nexusBackup.persistence.fsType }}
{{- end }}
{{- end }}
3 changes: 2 additions & 1 deletion stable/sonatype-nexus/templates/backup-pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.statefulset.enabled }}
{{- if and .Values.nexusBackup.enabled (and .Values.nexusBackup.persistence.enabled (not .Values.nexusBackup.persistence.existingClaim)) }}
kind: PersistentVolumeClaim
apiVersion: v1
Expand All @@ -23,4 +24,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}

{{- end }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{{- if .Values.statefulset.enabled }}
apiVersion: apps/v1beta1
kind: StatefulSet
{{- else }}
apiVersion: apps/v1beta2
kind: Deployment
{{- end }}
metadata:
name: {{ template "nexus.fullname" . }}
labels:
Expand All @@ -13,6 +18,13 @@ metadata:
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
{{- if .Values.statefulset.enabled }}
{{- if .Values.nexusProxy.svcName }}
serviceName: {{ .Values.nexusProxy.svcName }}
{{- else }}
serviceName: {{ template "nexus.fullname" . }}
{{- end }}
{{- end }}
{{- if .Values.deploymentStrategy }}
strategy:
{{ toYaml .Values.deploymentStrategy | indent 4 }}
Expand Down Expand Up @@ -84,9 +96,9 @@ spec:
{{- end }}
volumeMounts:
- mountPath: /nexus-data
name: nexus-data
name: {{ template "nexus.fullname" . }}-data
- mountPath: /nexus-data/backup
name: nexus-backup
name: {{ template "nexus.fullname" . }}-backup
{{- if .Values.config.enabled }}
- mountPath: {{ .Values.config.mountPath }}
name: {{ template "nexus.name" . }}-conf
Expand Down Expand Up @@ -180,9 +192,9 @@ spec:
value: .backup
volumeMounts:
- mountPath: /nexus-data
name: nexus-data
name: {{ template "nexus.fullname" . }}-data
- mountPath: /nexus-data/backup
name: nexus-backup
name: {{ template "nexus.fullname" . }}-backup
{{- end }}
{{- if .Values.deployment.additionalContainers }}
{{ toYaml .Values.deployment.additionalContainers | indent 8 }}
Expand All @@ -197,20 +209,32 @@ spec:
secret:
secretName: {{ template "nexus.proxy-ks.name" . }}
{{- end }}
- name: nexus-data

{{- if .Values.statefulset.enabled }}
{{- if not .Values.persistence.enabled }}
- name: {{ template "nexus.fullname" . }}-data
emptyDir: {}
{{- end }}
{{- if not (and .Values.nexusBackup.enabled .Values.nexusBackup.persistence.enabled) }}
- name: {{ template "nexus.fullname" . }}-backup
emptyDir: {}
{{- end }}
{{- else }}
- name: {{ template "nexus.fullname" . }}-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (printf "%s-%s" (include "nexus.fullname" .) "data") }}
{{- else }}
emptyDir: {}
{{- end }}
- name: nexus-backup
- name: {{ template "nexus.fullname" . }}-backup
{{- if and .Values.nexusBackup.enabled (.Values.nexusBackup.persistence.enabled) }}
persistentVolumeClaim:
claimName: {{ .Values.nexusBackup.persistence.existingClaim | default (printf "%s-%s" (include "nexus.fullname" .) "backup") }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{- if .Values.config.enabled }}
- name: {{ template "nexus.name" . }}-conf
configMap:
Expand All @@ -228,3 +252,56 @@ spec:
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}


## create pvc in case of statefulsets
{{- if .Values.statefulset.enabled }}
volumeClaimTemplates:
{{- if .Values.persistence.enabled }}
- metadata:
name: {{ template "nexus.fullname" . }}-data
labels:
{{ include "nexus.labels" . | indent 10 }}
{{- if .Values.persistence.annotations }}
annotations:
{{ toYaml .Values.persistence.annotations | indent 10 }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.storageSize | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}

{{- if and .Values.nexusBackup.enabled (.Values.nexusBackup.persistence.enabled) }}
- metadata:
name: {{ template "nexus.fullname" . }}-backup
labels:
{{ include "nexus.labels" . | indent 10 }}
{{- if .Values.nexusBackup.persistence.annotations }}
annotations:
{{ toYaml .Values.nexusBackup.persistence.annotations | indent 10 }}
{{- end }}
spec:
accessModes:
- {{ .Values.nexusBackup.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.nexusBackup.persistence.storageSize | quote }}
{{- if .Values.nexusBackup.persistence.storageClass }}
{{- if (eq "-" .Values.nexusBackup.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.nexusBackup.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
{{- end }}
5 changes: 4 additions & 1 deletion stable/sonatype-nexus/templates/proxy-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ spec:
selector:
app: {{ template "nexus.name" . }}
release: {{ .Release.Name }}
type: {{ .Values.nexus.serviceType }}
type: {{ .Values.nexus.service.type }}
{{- if and (eq .Values.nexus.service.type "ClusterIP") .Values.nexus.service.clusterIP }}
clusterIP: {{ .Values.nexus.service.clusterIP }}
{{- end }}
2 changes: 2 additions & 0 deletions stable/sonatype-nexus/templates/pv.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.statefulset.enabled }}
{{- if .Values.persistence.pdName -}}
apiVersion: v1
kind: PersistentVolume
Expand All @@ -17,3 +18,4 @@ spec:
pdName: {{ .Values.persistence.pdName }}
fsType: {{ .Values.persistence.fsType }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion stable/sonatype-nexus/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.statefulset.enabled }}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
Expand All @@ -22,4 +23,5 @@ spec:
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 5 additions & 1 deletion stable/sonatype-nexus/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
statefulset:
enabled: false
replicaCount: 1
# By default deploymentStrategy is set to rollingUpdate with maxSurge of 25% and maxUnavailable of 25% . you can change type to `Recreate` or can uncomment `rollingUpdate` specification and adjust them to your usage.
deploymentStrategy: {}
Expand Down Expand Up @@ -30,7 +32,9 @@ nexus:
# The ports should only be changed if the nexus image uses a different port
dockerPort: 5003
nexusPort: 8081
serviceType: NodePort
service:
type: NodePort
# clusterIP: None
# annotations: {}
# labels: {}
# securityContext:
Expand Down

0 comments on commit 49b4a37

Please sign in to comment.