mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-03-27 22:05:11 -02:30
Registry add TLS and authentication support (#8229)
* Add registry TLS support * Add registry configmap and htpasswd auth
This commit is contained in:
10
roles/kubernetes-apps/registry/templates/registry-cm.yml.j2
Normal file
10
roles/kubernetes-apps/registry/templates/registry-cm.yml.j2
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: registry-config
|
||||
namespace: {{ registry_namespace }}
|
||||
{% if registry_config %}
|
||||
data:
|
||||
config.yml: |-
|
||||
{{ registry_config | to_yaml(indent=2, width=1337) | indent(width=4) }}
|
||||
{% endif %}
|
||||
@@ -33,24 +33,60 @@ spec:
|
||||
- name: registry
|
||||
image: {{ registry_image_repo }}:{{ registry_image_tag }}
|
||||
imagePullPolicy: {{ k8s_image_pull_policy }}
|
||||
command:
|
||||
- /bin/registry
|
||||
- serve
|
||||
- /etc/docker/registry/config.yml
|
||||
env:
|
||||
- name: REGISTRY_HTTP_ADDR
|
||||
value: :{{ registry_port }}
|
||||
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
|
||||
value: /var/lib/registry
|
||||
{% if registry_htpasswd != "" %}
|
||||
- name: REGISTRY_AUTH
|
||||
value: "htpasswd"
|
||||
- name: REGISTRY_AUTH_HTPASSWD_REALM
|
||||
value: "Registry Realm"
|
||||
- name: REGISTRY_AUTH_HTPASSWD_PATH
|
||||
value: "/auth/htpasswd"
|
||||
{% endif %}
|
||||
{% if registry_tls_secret != "" %}
|
||||
- name: REGISTRY_HTTP_TLS_CERTIFICATE
|
||||
value: /etc/ssl/docker/tls.crt
|
||||
- name: REGISTRY_HTTP_TLS_KEY
|
||||
value: /etc/ssl/docker/tls.key
|
||||
{% endif %}
|
||||
volumeMounts:
|
||||
- name: registry-pvc
|
||||
mountPath: /var/lib/registry
|
||||
- name: registry-config
|
||||
mountPath: /etc/docker/registry
|
||||
{% if registry_htpasswd != "" %}
|
||||
- name: auth
|
||||
mountPath: /auth
|
||||
readOnly: true
|
||||
{% endif %}
|
||||
{% if registry_tls_secret != "" %}
|
||||
- name: tls-cert
|
||||
mountPath: /etc/ssl/docker
|
||||
readOnly: true
|
||||
{% endif %}
|
||||
ports:
|
||||
- containerPort: {{ registry_port }}
|
||||
name: registry
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
{% if registry_tls_secret != "" %}
|
||||
scheme: HTTPS
|
||||
{% endif %}
|
||||
path: /
|
||||
port: {{ registry_port }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
{% if registry_tls_secret != "" %}
|
||||
scheme: HTTPS
|
||||
{% endif %}
|
||||
path: /
|
||||
port: {{ registry_port }}
|
||||
volumes:
|
||||
@@ -60,4 +96,20 @@ spec:
|
||||
claimName: registry-pvc
|
||||
{% else %}
|
||||
emptyDir: {}
|
||||
{% endif %}
|
||||
- name: registry-config
|
||||
configMap:
|
||||
name: registry-config
|
||||
{% if registry_htpasswd != "" %}
|
||||
- name: auth
|
||||
secret:
|
||||
secretName: registry-secret
|
||||
items:
|
||||
- key: htpasswd
|
||||
path: htpasswd
|
||||
{% endif %}
|
||||
{% if registry_tls_secret != "" %}
|
||||
- name: tls-cert
|
||||
secret:
|
||||
secretName: {{ registry_tls_secret }}
|
||||
{% endif %}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: registry-secret
|
||||
namespace: {{ registry_namespace }}
|
||||
type: Opaque
|
||||
data:
|
||||
{% if registry_htpasswd != "" %}
|
||||
htpasswd: {{ registry_htpasswd | b64encode }}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user