From 38ff2dfcdaf020a2cc09a9e477ecb830d278bb7b Mon Sep 17 00:00:00 2001 From: Rob Kernick Date: Fri, 15 Sep 2017 06:26:01 -0400 Subject: [PATCH] Sonatype nexus helm chart (#1915) * Sonatype nexus helm chart * Updated chart per review * pvc: switch to storageClassName field * Change default service type --- stable/sonatype-nexus/.helmignore | 21 +++++ stable/sonatype-nexus/Chart.yaml | 16 ++++ stable/sonatype-nexus/README.md | 82 +++++++++++++++++++ stable/sonatype-nexus/templates/NOTES.txt | 19 +++++ stable/sonatype-nexus/templates/_helpers.tpl | 16 ++++ .../sonatype-nexus/templates/deployment.yaml | 53 ++++++++++++ stable/sonatype-nexus/templates/ingress.yaml | 32 ++++++++ stable/sonatype-nexus/templates/pvc.yaml | 24 ++++++ stable/sonatype-nexus/templates/service.yaml | 19 +++++ stable/sonatype-nexus/values.yaml | 55 +++++++++++++ 10 files changed, 337 insertions(+) create mode 100644 stable/sonatype-nexus/.helmignore create mode 100644 stable/sonatype-nexus/Chart.yaml create mode 100644 stable/sonatype-nexus/README.md create mode 100644 stable/sonatype-nexus/templates/NOTES.txt create mode 100644 stable/sonatype-nexus/templates/_helpers.tpl create mode 100644 stable/sonatype-nexus/templates/deployment.yaml create mode 100644 stable/sonatype-nexus/templates/ingress.yaml create mode 100644 stable/sonatype-nexus/templates/pvc.yaml create mode 100644 stable/sonatype-nexus/templates/service.yaml create mode 100644 stable/sonatype-nexus/values.yaml diff --git a/stable/sonatype-nexus/.helmignore b/stable/sonatype-nexus/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/sonatype-nexus/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/stable/sonatype-nexus/Chart.yaml b/stable/sonatype-nexus/Chart.yaml new file mode 100644 index 0000000000..41c5149ad7 --- /dev/null +++ b/stable/sonatype-nexus/Chart.yaml @@ -0,0 +1,16 @@ +name: sonatype-nexus +version: 0.1.0 +appVersion: 3.5.1 +description: Sonatype Nexus is an open source repository manager +keywords: + - dependency + - management + - sonatype + - repository +home: https://www.sonatype.com/nexus-repository-oss +icon: https://www.sonatype.com/hs-fs/hubfs/Sonatype_Logos/SON_logo_main.png?t=1504013727967&width=212&name=SON_logo_main.png +sources: + - https://github.com/clearent/nexus +maintainers: + - name: rjkernick + email: rjkernick@gmail.com diff --git a/stable/sonatype-nexus/README.md b/stable/sonatype-nexus/README.md new file mode 100644 index 0000000000..23033b3b19 --- /dev/null +++ b/stable/sonatype-nexus/README.md @@ -0,0 +1,82 @@ +# Nexus + +[Nexus](https://www.sonatype.com/nexus-repository-oss) is the world's only repository manager with FREE support for popular formats + +## Introduction + +This chart bootstraps a sonatype nexus instance + +## Prerequisites + +- Kubernetes 1.6+ + +## Installing the Chart + +To install the chart: + +```bash +$ helm install stable/sonatype-nexus +``` + +The above command deploys Nexus on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +The default login is admin/admin123 + +## Uninstalling the Chart + +to uninstall/delete the deployment: + +```bash +$ helm list +NAME REVISION UPDATED STATUS CHART NAMESPACE +plinking-gopher 1 Fri Sep 1 13:19:50 2017 DEPLOYED nexus-0.1.0 default +$ helm delete plinking-gopher +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the Nexus chart and their default values. + +| Parameter | Description | Default | +| ------------------------------------------ | ---------------------------------- | -------------------------------------------| +| `imageTag` | `nexus` image tag. | 3.5.1-02 | +| `imagePullPolicy` | Image pull policy | `IfNotPresent` | +| `ingress.enabled` | Flag for enabling ingress | false | +| `persistence.enabled` | Create a volume to store data | true | +| `persistence.size` | Size of persistent volume to claim | 8Gi RW | +| `persistence.storageClass` | Type of persistent volume claim | nil (uses alpha storage class annotation) | +| `persistence.accessMode` | ReadWriteOnce or ReadOnly | ReadWriteOnce | +| `service.type` | Kubernetes Service type | `ClusterIP` | +| `service.readinessProbe.initialDelaySeconds`| ReadinessProbe initial delay | 30 | +| `service.readinessProbe.periodSeconds` | Seconds between polls | 30 | +| `service.readinessProbe.failureThreshold` | Number of attempts before failure | 6 | +| `service.livenessProbe.initialDelaySeconds` | livenessProbe initial delay | 30 | +| `service.livenessProbe.periodSeconds` | Seconds between polls | 30 | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install --name my-release \ + --set persistence.enabled=false \ + stable/sonatype-nexus +``` +The above example turns off the persistence. Data will not be kept between restarts or deployments + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name my-release -f values.yaml stable/sonatype-nexus +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## Persistence + +The [Nexus](https://github.com/clearent/nexus) image stores its data and configurations at the `/nexus-data` path of the container. + +By default a PersistentVolumeClaim is created and mounted into that directory. In order to disable this functionality +you can change the values.yaml to disable persistence and use an emptyDir instead. + +> *"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."* diff --git a/stable/sonatype-nexus/templates/NOTES.txt b/stable/sonatype-nexus/templates/NOTES.txt new file mode 100644 index 0000000000..a8ad40eb84 --- /dev/null +++ b/stable/sonatype-nexus/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http://{{ . }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.externalPort }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8081 to use your application" + kubectl port-forward $POD_NAME 8081:{{ .Values.service.externalPort }} +{{- end }} diff --git a/stable/sonatype-nexus/templates/_helpers.tpl b/stable/sonatype-nexus/templates/_helpers.tpl new file mode 100644 index 0000000000..f0d83d2edb --- /dev/null +++ b/stable/sonatype-nexus/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/stable/sonatype-nexus/templates/deployment.yaml b/stable/sonatype-nexus/templates/deployment.yaml new file mode 100644 index 0000000000..abd322fe2b --- /dev/null +++ b/stable/sonatype-nexus/templates/deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selector: + matchLabels: + app: {{ template "name" . }} + release: {{ .Release.Name }} + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.internalPort }} + livenessProbe: + httpGet: + path: / + port: {{ .Values.service.internalPort }} + initialDelaySeconds: {{ .Values.service.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.service.livenessProbe.periodSeconds }} + readinessProbe: + httpGet: + path: / + port: {{ .Values.service.internalPort }} + initialDelaySeconds: {{ .Values.service.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.service.readinessProbe.periodSeconds }} + failureThreshold: {{ .Values.service.readinessProbe.failureThreshold }} + volumeMounts: + - mountPath: /nexus-data + name: nexus-data-volume + volumes: + - name: nexus-data-volume + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ template "fullname" . }} + {{- else }} + emptyDir: {} + {{- end -}} diff --git a/stable/sonatype-nexus/templates/ingress.yaml b/stable/sonatype-nexus/templates/ingress.yaml new file mode 100644 index 0000000000..b09eb9075a --- /dev/null +++ b/stable/sonatype-nexus/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/stable/sonatype-nexus/templates/pvc.yaml b/stable/sonatype-nexus/templates/pvc.yaml new file mode 100644 index 0000000000..439abccbaf --- /dev/null +++ b/stable/sonatype-nexus/templates/pvc.yaml @@ -0,0 +1,24 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/stable/sonatype-nexus/templates/service.yaml b/stable/sonatype-nexus/templates/service.yaml new file mode 100644 index 0000000000..f311d10a0d --- /dev/null +++ b/stable/sonatype-nexus/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: {{ .Values.service.name }} + selector: + app: {{ template "name" . }} + release: {{ .Release.Name }} diff --git a/stable/sonatype-nexus/values.yaml b/stable/sonatype-nexus/values.yaml new file mode 100644 index 0000000000..48cd4f9dbf --- /dev/null +++ b/stable/sonatype-nexus/values.yaml @@ -0,0 +1,55 @@ +# Default values for nexus. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: + repository: clearent/nexus + tag: 3.5.1-02 +service: + name: nexus + type: LoadBalancer + externalPort: 8081 + internalPort: 8081 + readinessProbe: + initialDelaySeconds: 30 + periodSeconds: 30 + failureThreshold: 6 + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 30 +ingress: + enabled: false + # Used to create an Ingress record. + # hosts: + # - nexus.local + # annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # tls: {} + # Secrets must be manually created in the namespace. + # - secretName: nexus-tls + # hosts: + # - nexus.local +## Persist data to a persitent volume +persistence: + enabled: true + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + accessMode: ReadWriteOnce + size: 8Gi +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi