helmfile.yaml 4.15 KB
environments:
  default:
    values:
      - namespace: registry
        namePrefix: "test-"
        restoreFromEmpty:
          enabled: true
        registry:
          jsonPatches: []
          strategicMergePatches: []
          service:
            registry:
              nodePort: 32123
        istioVirtualService:
          enabled: true
          jsonPatches: []
          strategicMergePatches: []
          gateways:
            - default/cluster-local-gateway
          vhosts:
            - registry.local
        images:
          debian: "debian:bullseye-20211220"
          registry: "registry:2"
          redis: "redis:6.2.6"
---
helmfiles:
  - path: ../redis/helmfile.yaml
    values:
      - namespace: {{ .Values.namespace }}
        namePrefix: {{ .Values.namePrefix }}registry-
        images:
          redis: {{ .Values.images.redis }}

releases:
  - name: {{ .Values.namePrefix }}registry
    namespace: {{ .Values.namespace }}
    chart: .
    values:
      - set-common-values.yaml.gotmpl
    jsonPatches:
      - target:
          kind: Service
          name: {{ .Values.namePrefix }}registry
          namespace: {{ .Values.namespace }}
          version: v1
        patch:
          - op: replace
            path: /spec/selector/app
            value: {{ .Values.namePrefix }}registry
          - op: replace
            path: /spec/ports/0/nodePort
            value: {{ .Values.registry.service.registry.nodePort }}
      {{- if .Values.istioVirtualService.enabled }}
      - target:
          kind: VirtualService
          name: {{ .Values.namePrefix }}registry
          namespace: {{ .Values.namespace }}
          version: v1beta1
          group: networking.istio.io
        patch:
          - op: replace
            path: /spec/http/0/route/0/destination/host
            value: {{ .Values.namePrefix }}registry
      {{- end }}
      {{- if not (empty (.Values.registry.jsonPatches)) }}
      {{- .Values.registry.jsonPatches | toYaml | indent 6 }}
      {{- end }}
    strategicMergePatches:
      - apiVersion: networking.istio.io/v1beta1
        kind: VirtualService
        metadata:
          name: {{ .Values.namePrefix }}registry
          namespace: {{ .Values.namespace }}
      {{- if .Values.istioVirtualService.enabled }}
        spec:
          hosts:
            {{- range $vhost_index, $vhost := .Values.istioVirtualService.vhosts }}
            - {{ $vhost | quote }}
            {{- end }}
          gateways:
            {{- range $gateway_index, $gateway := .Values.istioVirtualService.gateways }}
            - {{ $gateway | quote }}
            {{- end }}
      {{- else }}
        $patch: delete
      {{- end }}
      - apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: {{ .Values.namePrefix }}registry
          namespace: {{ .Values.namespace }}
        spec:
          selector:
            matchLabels:
              app: {{ .Values.namePrefix }}registry
          template:
            metadata:
              labels:
                app: {{ .Values.namePrefix }}registry
            spec:
              volumes:
                - name: registry-data
                  persistentVolumeClaim:
                    claimName: {{ .Values.namePrefix }}registry-data
              containers:
                - name: registry
                  envFrom:
                    - configMapRef:
                        name: {{ .Values.namePrefix }}registry-config
                    - secretRef:
                        name: {{ .Values.namePrefix }}registry-secret
      - apiVersion: v1
        kind: ConfigMap
        metadata:
          name: {{ .Values.namePrefix }}registry-config
          namespace: {{ .Values.namespace }}
        data:
          REGISTRY_REDIS_ADDR: {{ .Values.namePrefix }}registry-redis.{{ .Values.namespace }}.svc.cluster.local
          REGISTRY_STORAGE_CACHE_BLOBDESCRIPTOR: redis
      - apiVersion: v1
        kind: Secret
        metadata:
          name: {{ .Values.namePrefix }}registry-secret
          namespace: {{ .Values.namespace }}
        stringData:
      {{- if not (empty (.Values.registry.strategicMergePatches)) }}
      {{- .Values.registry.strategicMergePatches | toYaml | indent 6 }}
      {{- end }}