Skip to content

Commit

Permalink
Handle registry proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Jul 18, 2024
1 parent 8a97434 commit ffd4c7b
Show file tree
Hide file tree
Showing 26 changed files with 253 additions and 16 deletions.
1 change: 1 addition & 0 deletions apis/ui/v1alpha1/dbgate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Dbgate struct {
}

type DbgateSpec struct {
Proxies RegistryProxies `json:"proxies"`
ReplicaCount int `json:"replicaCount"`
Image ImageRef `json:"image"`
ImagePullSecrets []string `json:"imagePullSecrets"`
Expand Down
1 change: 1 addition & 0 deletions apis/ui/v1alpha1/mongo_ui_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type MongoUi struct {
}

type MongoUiSpec struct {
Proxies RegistryProxies `json:"proxies"`
ReplicaCount int `json:"replicaCount"`
Image ImageRef `json:"image"`
ImagePullSecrets []string `json:"imagePullSecrets"`
Expand Down
1 change: 1 addition & 0 deletions apis/ui/v1alpha1/pgadmin_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Pgadmin struct {
}

type PgadminSpec struct {
Proxies RegistryProxies `json:"proxies"`
ReplicaCount int `json:"replicaCount"`
Image ImageRef `json:"image"`
ImagePullSecrets []string `json:"imagePullSecrets"`
Expand Down
1 change: 1 addition & 0 deletions apis/ui/v1alpha1/phpmyadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Phpmyadmin struct {
}

type PhpmyadminSpec struct {
Proxies RegistryProxies `json:"proxies"`
ReplicaCount int `json:"replicaCount"`
Image ImageRef `json:"image"`
ImagePullSecrets []string `json:"imagePullSecrets"`
Expand Down
21 changes: 21 additions & 0 deletions apis/ui/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ package v1alpha1

import core "k8s.io/api/core/v1"

type RegistryProxies struct {
// company/bin:1.23
//+optional
DockerHub string `json:"dockerHub"`
// alpine, nginx etc.
//+optional
DockerLibrary string `json:"dockerLibrary"`
// ghcr.io
//+optional
GHCR string `json:"ghcr"`
// registry.k8s.io
//+optional
Kubernetes string `json:"kubernetes"`
// mcr.microsoft.com
//+optional
Microsoft string `json:"microsoft"`
// r.appscode.com
//+optional
AppsCode string `json:"appscode"`
}

type ImageRef struct {
Repository string `json:"repository"`
PullPolicy string `json:"pullPolicy"`
Expand Down
20 changes: 20 additions & 0 deletions apis/ui/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion charts/dbgate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ The following table lists the configurable parameters of the `dbgate` chart and

| Parameter | Description | Default |
|------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| proxies.dockerHub | | <code>""</code> |
| proxies.dockerLibrary | | <code>""</code> |
| proxies.ghcr | | <code>ghcr.io</code> |
| proxies.kubernetes | | <code>registry.k8s.io</code> |
| proxies.microsoft | | <code>mcr.microsoft.com</code> |
| proxies.appscode | | <code>r.appscode.com</code> |
| replicaCount | | <code>1</code> |
| image.repository | | <code>"dbgate/dbgate"</code> |
| image.pullPolicy | | <code>Always</code> |
Expand Down Expand Up @@ -85,7 +91,7 @@ The following table lists the configurable parameters of the `dbgate` chart and
| bind.name | | <code>""</code> |
| bind.namespace | | <code>""</code> |
| authzproxy.enabled | | <code>false</code> |
| authzproxy.repository | KubeDB operator container image | <code>ghcr.io/appscode/kube-authz-proxy</code> |
| authzproxy.repository | KubeDB operator container image | <code>appscode/kube-authz-proxy</code> |
| authzproxy.tag | KubeDB operator container image tag | <code>"v0.0.1"</code> |
| authzproxy.securityContext | Security options this container should run with | <code>{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":65534,"seccompProfile":{"type":"RuntimeDefault"}}</code> |
| authzproxy.resources | Compute Resources required by this container | <code>{}</code> |
Expand Down
12 changes: 12 additions & 0 deletions charts/dbgate/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,15 @@ Fake keda hostname
{{- define "keda.hostname" -}}
{{- printf "dbgate.%s.%s.%s.%s.kubedb.test" .Values.bind.name .Values.bind.namespace .Values.app.service.name .Values.app.service.namespace | quote }}
{{- end }}

{{- define "image.dockerHub" -}}
{{ list .Values.proxies.dockerHub ._repo | compact | join "/" }}
{{- end }}

{{- define "image.dockerLibrary" -}}
{{ prepend (list ._repo) (list .Values.proxies.dockerLibrary .Values.proxies.dockerHub | compact | first) | compact | join "/" }}
{{- end }}

{{- define "image.ghcr" -}}
{{ list .Values.proxies.ghcr ._repo | compact | join "/" }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/dbgate/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
- name: authz-proxy
securityContext:
{{- toYaml .Values.authzproxy.securityContext | nindent 12 }}
image: "{{ .Values.authzproxy.repository }}:{{ .Values.authzproxy.tag | default .Chart.AppVersion }}"
image: '{{ include "image.ghcr" (merge (dict "_repo" $.Values.authzproxy.repository) $) }}:{{ .Values.authzproxy.tag | default .Chart.AppVersion }}'
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- run
Expand Down Expand Up @@ -80,7 +80,7 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: '{{ include "image.dockerHub" (merge (dict "_repo" $.Values.image.repository) $) }}:{{ .Values.image.tag | default .Chart.AppVersion }}'
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: CONNECTIONS
Expand Down
22 changes: 22 additions & 0 deletions charts/dbgate/values.openapiv3_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,27 @@ properties:
type: string
type: object
type: object
proxies:
properties:
appscode:
description: r.appscode.com
type: string
dockerHub:
description: company/bin:1.23
type: string
dockerLibrary:
description: alpine, nginx etc.
type: string
ghcr:
description: ghcr.io
type: string
kubernetes:
description: registry.k8s.io
type: string
microsoft:
description: mcr.microsoft.com
type: string
type: object
replicaCount:
type: integer
resources:
Expand Down Expand Up @@ -1762,6 +1783,7 @@ required:
- nodeSelector
- podAnnotations
- podSecurityContext
- proxies
- replicaCount
- resources
- securityContext
Expand Down
10 changes: 9 additions & 1 deletion charts/dbgate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

proxies:
dockerHub: ""
dockerLibrary: ""
ghcr: ghcr.io
kubernetes: registry.k8s.io
microsoft: mcr.microsoft.com
appscode: r.appscode.com

replicaCount: 1

image:
Expand Down Expand Up @@ -126,7 +134,7 @@ bind:
authzproxy:
enabled: false
# KubeDB operator container image
repository: ghcr.io/appscode/kube-authz-proxy
repository: appscode/kube-authz-proxy
# KubeDB operator container image tag
tag: "v0.0.1"
# Security options this container should run with
Expand Down
Loading

0 comments on commit ffd4c7b

Please sign in to comment.