Anteriormente queria desplegar un bitbucket (porque gitlab come una barbaridad), no hubo problema en crearse un manifiesto yaml y seguir adelante pero un helm de bitbucket nunca viene mal.
Lo primero para crear un charts es:
helm create bitbucket
Probamos que funciona
helm install bitbucket
Por defecto viene una imagen nginx asi que lo cambiamos por bitbucket en values.yaml en la seccion image
image: repository: atlassian/bitbucket-server tag: latest pullPolicy: IfNotPresent
Tambien tenemos que cambiar el puerto 80 a 7990 que es lo que usa bitbucket
service: type: ClusterIP port: 7990
Configuracmos el service template yaml
apiVersion: v1 kind: Service metadata: name: {{ include "bitbucket.fullname" . }} labels: {{ include "bitbucket.labels" . | indent 4 }} spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} targetPort: 7990 protocol: TCP name: http selector: app.kubernetes.io/name: {{ include "bitbucket.name" . }} app.kubernetes.io/instance: {{ .Release.Name }}
Ahora vamos a configurar la persistencia, primero lo añadimos en el values.yaml
persistence: enabled: true bitbucket: accessMode: ReadWriteOnce size: 8Gi
Helm create no añade las secciones de persitencia ni cluster storage asi que tenemos que añadirlas.
Creamos un una template pvc yaml dentro bitbucket/templates/bitbucket-pvc.yaml
{{- if .Values.persistence.enabled -}} kind: PersistentVolumeClaim apiVersion: v1 metadata: name: {{ template "bitbucket.fullname" . }}-bitbucket labels: app: {{ template "bitbucket.name" . }} chart: {{ template "bitbucket.chart" . }} release: {{ .Release.Name | quote }} heritage: {{ .Release.Service | quote }} spec: accessModes: - {{ .Values.persistence.bitbucket.accessMode | quote }} resources: requests: storage: {{ .Values.persistence.bitbucket.size | quote }} {{ include "bitbucket.storageClass" . }} {{- end -}}
Configurar los volumenes en el deployment.yaml especificos de bitbucket
apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "bitbucket.fullname" . }} labels: {{ include "bitbucket.labels" . | indent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app.kubernetes.io/name: {{ include "bitbucket.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} template: metadata: labels: app.kubernetes.io/name: {{ include "bitbucket.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http containerPort: 7990 protocol: TCP volumeMounts: - name: {{ template "bitbucket.fullname" . }}-bitbucket-volume mountPath: "/var/atlassian/application-data/bitbucket" volumes: - name: {{ template "bitbucket.fullname" . }}-bitbucket-volume persistentVolumeClaim: claimName: {{ template "bitbucket.fullname" . }}-bitbucket resources: {{- toYaml .Values.resources | nindent 12 }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }}
Ahroa solo queda añadir la seccion que se conecta a un clusterStorage del cluster en el archivos _helpers.tpl
{{/* Return the proper Storage Class */}} {{- define "bitbucket.storageClass" -}} {{/* Helm 2.11 supports the assignment of a value to a variable defined in a different scope, but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic. */}} {{- if .Values.global -}} {{- if .Values.global.storageClass -}} {{- if (eq "-" .Values.global.storageClass) -}} {{- printf "storageClassName: \"\"" -}} {{- else }} {{- printf "storageClassName: %s" .Values.global.storageClass -}} {{- end -}} {{- else -}} {{- if .Values.persistence.bitbucket.storageClass -}} {{- if (eq "-" .Values.persistence.bitbucket.storageClass) -}} {{- printf "storageClassName: \"\"" -}} {{- else }} {{- printf "storageClassName: %s" .Values.persistence.bitbucket.storageClass -}} {{- end -}} {{- end -}} {{- end -}} {{- else -}} {{- if .Values.persistence.bitbucket.storageClass -}} {{- if (eq "-" .Values.persistence.bitbucket.storageClass) -}} {{- printf "storageClassName: \"\"" -}} {{- else }} {{- printf "storageClassName: %s" .Values.persistence.bitbucket.storageClass -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}}
Con esto ya podriamos desplegar y si ponemos LoadBalancer en el servicio usarlo pero ya que estamos vamos a configurar el ingress
Añadimos la seccion ingress al values configurando el hosts para el dns kluster.cf
ingress: enabled: true annotations: { "kubernetes.io/ingress.class": "nginx", "kubernetes.io/tls-acme": "false" } # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - host: kluster.cf paths: / tls: ["/"] # - secretName: chart-example-tls # hosts: # - chart-example.local
Ya solo queda hacer:
helm install bitbucket –name bitbcuket
Y ya hemos desplegado bitbucket con helm
https://github.com/Akaronte/bitbucket-chart
0 comentarios