diff --git a/.gitignore b/.gitignore index e17d8e0..2a5985c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ .idea/ -charts/ ui diff --git a/Dockerfile b/Dockerfile index 3a7fdbd..9b9fd55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM library/golang:1 as builder # Godep for vendoring -RUN go get github.com/tools/godep +RUN go install github.com/tools/godep@master # Recompile the standard library without CGO RUN CGO_ENABLED=0 go install -a std diff --git a/charts/chartmuseum-ui/.helmignore b/charts/chartmuseum-ui/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/chartmuseum-ui/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/chartmuseum-ui/Chart.yaml b/charts/chartmuseum-ui/Chart.yaml new file mode 100644 index 0000000..92fc603 --- /dev/null +++ b/charts/chartmuseum-ui/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: chartmuseum-ui +description: A Helm chart for Chartmuseum-ui +type: application +version: 0.0.1 +appVersion: "0.0.1" diff --git a/charts/chartmuseum-ui/templates/_helpers.tpl b/charts/chartmuseum-ui/templates/_helpers.tpl new file mode 100644 index 0000000..1ae99d6 --- /dev/null +++ b/charts/chartmuseum-ui/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "chartmuseum-ui.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). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "chartmuseum-ui.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "chartmuseum-ui.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "chartmuseum-ui.labels" -}} +helm.sh/chart: {{ include "chartmuseum-ui.chart" . }} +{{ include "chartmuseum-ui.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "chartmuseum-ui.selectorLabels" -}} +app.kubernetes.io/name: {{ include "chartmuseum-ui.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Pdb apiVersion according k8s version and capabilities +*/}} +{{- define "chartmuseum-ui.pdb.apiVersion" -}} +{{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion) -}} +policy/v1 +{{- else -}} +policy/v1beta1 +{{- end }} +{{- end -}} diff --git a/charts/chartmuseum-ui/templates/deployment.yaml b/charts/chartmuseum-ui/templates/deployment.yaml new file mode 100644 index 0000000..cc5cc40 --- /dev/null +++ b/charts/chartmuseum-ui/templates/deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "chartmuseum-ui.fullname" . }} + labels: + {{- include "chartmuseum-ui.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "chartmuseum-ui.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "chartmuseum-ui.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.serviceAccountName }} + serviceAccountName: {{ . }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: CHART_MUSEUM_URL + value: {{ .Values.app.chartmuseumUrl }} + {{- with .Values.app.extraEnv }} + {{- toYaml .| nindent 12 }} + {{- end }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + 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 }} diff --git a/charts/chartmuseum-ui/templates/hpa.yaml b/charts/chartmuseum-ui/templates/hpa.yaml new file mode 100644 index 0000000..7c3389b --- /dev/null +++ b/charts/chartmuseum-ui/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "chartmuseum-ui.fullname" . }} + labels: + {{- include "chartmuseum-ui.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "chartmuseum-ui.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/chartmuseum-ui/templates/ingress.yaml b/charts/chartmuseum-ui/templates/ingress.yaml new file mode 100644 index 0000000..878a942 --- /dev/null +++ b/charts/chartmuseum-ui/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "chartmuseum-ui.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "chartmuseum-ui.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/chartmuseum-ui/templates/pdb.yaml b/charts/chartmuseum-ui/templates/pdb.yaml new file mode 100644 index 0000000..be5b72b --- /dev/null +++ b/charts/chartmuseum-ui/templates/pdb.yaml @@ -0,0 +1,20 @@ +{{- if .Values.podDisruptionBudget.enabled }} +apiVersion: {{ include "chartmuseum-ui.pdb.apiVersion" . }} +kind: PodDisruptionBudget +metadata: + name: {{ include "chartmuseum-ui.fullname" . }} + labels: + {{- include "chartmuseum-ui.labels" . | nindent 4 }} +{{- with .Values.podDisruptionBudget.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + selector: + matchLabels: + {{- include "chartmuseum-ui.selectorLabels" . | nindent 6 }} + {{- with .Values.labels }} + {{- toYaml . | nindent 6 }} + {{- end }} +{{- end }} diff --git a/charts/chartmuseum-ui/templates/service.yaml b/charts/chartmuseum-ui/templates/service.yaml new file mode 100644 index 0000000..dc3f584 --- /dev/null +++ b/charts/chartmuseum-ui/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "chartmuseum-ui.fullname" . }} + labels: + {{- include "chartmuseum-ui.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "chartmuseum-ui.selectorLabels" . | nindent 4 }} diff --git a/charts/chartmuseum-ui/values.yaml b/charts/chartmuseum-ui/values.yaml new file mode 100644 index 0000000..35c8f23 --- /dev/null +++ b/charts/chartmuseum-ui/values.yaml @@ -0,0 +1,83 @@ +# Default values for chartmuseum-ui. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: tombokombo/chartmuseum-ui + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +app: + chartmuseumUrl: http://chartmuseum.example.local + extraEnv: [] + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +# serviceAccountName: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chartmuseum-ui.example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: + - hosts: + - chartmuseum.kube.shared.pxfd.tech + + +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 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +podDisruptionBudget: + enabled: false + maxUnavailable: 1