Browse Source
Merge pull request #2332 from hswong3i/registry_fixup
Merge pull request #2332 from hswong3i/registry_fixup
Registry Addon Fixuppull/2333/head
Spencer Smith
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 137 additions and 696 deletions
Split View
Diff Options
-
3inventory/sample/group_vars/k8s-cluster.yml
-
89roles/kubernetes-apps/registry/README.md
-
4roles/kubernetes-apps/registry/defaults/main.yml
-
26roles/kubernetes-apps/registry/files/images/Dockerfile
-
24roles/kubernetes-apps/registry/files/images/Makefile
-
23roles/kubernetes-apps/registry/files/images/rootfs/bin/boot
-
28roles/kubernetes-apps/registry/files/images/rootfs/etc/nginx/conf.d/default.conf.in
-
6roles/kubernetes-apps/registry/files/images/rootfs/etc/nginx/docker-registry.conf
-
26roles/kubernetes-apps/registry/files/images/rootfs/etc/nginx/nginx.conf
-
37roles/kubernetes-apps/registry/tasks/main.yml
-
92roles/kubernetes-apps/registry/templates/auth/README.md
-
56roles/kubernetes-apps/registry/templates/auth/registry-auth-rc.yml.j2
-
81roles/kubernetes-apps/registry/templates/gcs/README.md
-
52roles/kubernetes-apps/registry/templates/gcs/registry-gcs-rc.yml.j2
-
7roles/kubernetes-apps/registry/templates/registry-ns.yml.j2
-
21roles/kubernetes-apps/registry/templates/registry-proxy-ds.yml.j2
-
17roles/kubernetes-apps/registry/templates/registry-pv.yml.j2
-
10roles/kubernetes-apps/registry/templates/registry-pvc.yml.j2
-
27roles/kubernetes-apps/registry/templates/registry-rs.yml.j2
-
14roles/kubernetes-apps/registry/templates/registry-svc.yml.j2
-
116roles/kubernetes-apps/registry/templates/tls/README.md
-
57roles/kubernetes-apps/registry/templates/tls/registry-tls-rc.yml.j2
-
17roles/kubernetes-apps/registry/templates/tls/registry-tls-svc.yml.j2
@ -1,26 +0,0 @@ |
|||
# Copyright 2016 The Kubernetes Authors. |
|||
# |
|||
# Licensed under the Apache License, Version 2.0 (the "License"); |
|||
# you may not use this file except in compliance with the License. |
|||
# You may obtain a copy of the License at |
|||
# |
|||
# http://www.apache.org/licenses/LICENSE-2.0 |
|||
# |
|||
# Unless required by applicable law or agreed to in writing, software |
|||
# distributed under the License is distributed on an "AS IS" BASIS, |
|||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
# See the License for the specific language governing permissions and |
|||
# limitations under the License. |
|||
|
|||
FROM nginx:1.12 |
|||
|
|||
RUN apt-get update \ |
|||
&& apt-get install -y \ |
|||
curl \ |
|||
--no-install-recommends \ |
|||
&& apt-get clean \ |
|||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man /usr/share/doc |
|||
|
|||
COPY rootfs / |
|||
|
|||
CMD ["/bin/boot"] |
@ -1,24 +0,0 @@ |
|||
# Copyright 2016 The Kubernetes Authors.
|
|||
#
|
|||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|||
# you may not use this file except in compliance with the License.
|
|||
# You may obtain a copy of the License at
|
|||
#
|
|||
# http://www.apache.org/licenses/LICENSE-2.0
|
|||
#
|
|||
# Unless required by applicable law or agreed to in writing, software
|
|||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
# See the License for the specific language governing permissions and
|
|||
# limitations under the License.
|
|||
|
|||
.PHONY: build push vet test clean |
|||
|
|||
TAG = 0.4 |
|||
REPO = gcr.io/google_containers/kube-registry-proxy |
|||
|
|||
build: |
|||
docker build --pull -t $(REPO):$(TAG) . |
|||
|
|||
push: |
|||
gcloud docker -- push $(REPO):$(TAG) |
@ -1,23 +0,0 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
# fail if no hostname is provided |
|||
REGISTRY_HOST=${REGISTRY_HOST:?no host} |
|||
REGISTRY_PORT=${REGISTRY_PORT:-5000} |
|||
|
|||
# we are always listening on port 80 |
|||
# https://github.com/nginxinc/docker-nginx/blob/43c112100750cbd1e9f2160324c64988e7920ac9/stable/jessie/Dockerfile#L25 |
|||
PORT=80 |
|||
|
|||
sed -e "s/%HOST%/$REGISTRY_HOST/g" \ |
|||
-e "s/%PORT%/$REGISTRY_PORT/g" \ |
|||
-e "s/%BIND_PORT%/$PORT/g" \ |
|||
</etc/nginx/conf.d/default.conf.in >/etc/nginx/conf.d/default.conf |
|||
|
|||
# wait for registry to come online |
|||
while ! curl -sS "$REGISTRY_HOST:$REGISTRY_PORT" &>/dev/null; do |
|||
printf "waiting for the registry (%s:%s) to come online...\n" "$REGISTRY_HOST" "$REGISTRY_PORT" |
|||
sleep 1 |
|||
done |
|||
|
|||
printf "starting proxy...\n" |
|||
exec nginx -g "daemon off;" "$@" |
@ -1,28 +0,0 @@ |
|||
# Docker registry proxy for api version 2 |
|||
|
|||
upstream docker-registry { |
|||
server %HOST%:%PORT%; |
|||
} |
|||
|
|||
# No client auth or TLS |
|||
# TODO(bacongobbler): experiment with authenticating the registry if it's using TLS |
|||
server { |
|||
listen %BIND_PORT%; |
|||
server_name localhost; |
|||
|
|||
# disable any limits to avoid HTTP 413 for large image uploads |
|||
client_max_body_size 0; |
|||
|
|||
# required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486) |
|||
chunked_transfer_encoding on; |
|||
|
|||
location / { |
|||
# Do not allow connections from docker 1.5 and earlier |
|||
# docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents |
|||
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) { |
|||
return 404; |
|||
} |
|||
|
|||
include docker-registry.conf; |
|||
} |
|||
} |
@ -1,6 +0,0 @@ |
|||
proxy_pass http://docker-registry; |
|||
proxy_set_header Host $http_host; # required for docker client's sake |
|||
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP |
|||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|||
proxy_set_header X-Forwarded-Proto $scheme; |
|||
proxy_read_timeout 900; |
@ -1,26 +0,0 @@ |
|||
user nginx; |
|||
worker_processes auto; |
|||
|
|||
error_log /var/log/nginx/error.log warn; |
|||
pid /var/run/nginx.pid; |
|||
|
|||
events { |
|||
worker_connections 1024; |
|||
} |
|||
|
|||
http { |
|||
include /etc/nginx/mime.types; |
|||
default_type application/octet-stream; |
|||
|
|||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
|||
'$status $body_bytes_sent "$http_referer" ' |
|||
'"$http_user_agent" "$http_x_forwarded_for"'; |
|||
|
|||
access_log /var/log/nginx/access.log main; |
|||
|
|||
sendfile on; |
|||
|
|||
keepalive_timeout 65; |
|||
|
|||
include /etc/nginx/conf.d/*.conf; |
|||
} |
@ -1,92 +0,0 @@ |
|||
# Enable Authentication with Htpasswd for Kube-Registry |
|||
|
|||
Docker registry support a few authentication providers. Full list of supported provider can be found [here](https://docs.docker.com/registry/configuration/#auth). This document describes how to enable authentication with htpasswd for kube-registry. |
|||
|
|||
### Prepare Htpasswd Secret |
|||
|
|||
Please generate your own htpasswd file. Assuming the file you generated is `htpasswd`. |
|||
Creating secret to hold htpasswd... |
|||
```console |
|||
$ kubectl --namespace=kube-system create secret generic registry-auth-secret --from-file=htpasswd=htpasswd |
|||
``` |
|||
|
|||
### Run Registry |
|||
|
|||
Please be noted that this sample rc is using emptyDir as storage backend for simplicity. |
|||
|
|||
<!-- BEGIN MUNGE: EXAMPLE registry-auth-rc.yaml --> |
|||
```yaml |
|||
apiVersion: v1 |
|||
kind: ReplicationController |
|||
metadata: |
|||
name: kube-registry-v0 |
|||
namespace: kube-system |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
template: |
|||
metadata: |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
containers: |
|||
- name: registry |
|||
image: registry:2 |
|||
resources: |
|||
# keep request = limit to keep this container in guaranteed class |
|||
limits: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
requests: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
env: |
|||
- name: REGISTRY_HTTP_ADDR |
|||
value: :5000 |
|||
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY |
|||
value: /var/lib/registry |
|||
- name: REGISTRY_AUTH_HTPASSWD_REALM |
|||
value: basic_realm |
|||
- name: REGISTRY_AUTH_HTPASSWD_PATH |
|||
value: /auth/htpasswd |
|||
volumeMounts: |
|||
- name: image-store |
|||
mountPath: /var/lib/registry |
|||
- name: auth-dir |
|||
mountPath: /auth |
|||
ports: |
|||
- containerPort: 5000 |
|||
name: registry |
|||
protocol: TCP |
|||
volumes: |
|||
- name: image-store |
|||
emptyDir: {} |
|||
- name: auth-dir |
|||
secret: |
|||
secretName: registry-auth-secret |
|||
``` |
|||
<!-- END MUNGE: EXAMPLE registry-auth-rc.yaml --> |
|||
|
|||
No changes are needed for other components (kube-registry service and proxy). |
|||
|
|||
### To Verify |
|||
|
|||
Setup proxy or port-forwarding to the kube-registry. Image push/pull should fail without authentication. Then use `docker login` to authenticate with kube-registry and see if it works. |
|||
|
|||
### Configure Nodes to Authenticate with Kube-Registry |
|||
|
|||
By default, nodes assume no authentication is required by kube-registry. Without authentication, nodes cannot pull images from kube-registry. To solve this, more documentation can be found [Here](https://github.com/kubernetes/kubernetes.github.io/blob/master/docs/concepts/containers/images.md#configuring-nodes-to-authenticate-to-a-private-repository). |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/addons/registry/auth/README.md?pixel)]() |
@ -1,56 +0,0 @@ |
|||
apiVersion: v1 |
|||
kind: ReplicationController |
|||
metadata: |
|||
name: kube-registry-v0 |
|||
namespace: kube-system |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
template: |
|||
metadata: |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
containers: |
|||
- name: registry |
|||
image: registry:2 |
|||
resources: |
|||
# keep request = limit to keep this container in guaranteed class |
|||
limits: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
requests: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
env: |
|||
- name: REGISTRY_HTTP_ADDR |
|||
value: :5000 |
|||
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY |
|||
value: /var/lib/registry |
|||
- name: REGISTRY_AUTH_HTPASSWD_REALM |
|||
value: basic_realm |
|||
- name: REGISTRY_AUTH_HTPASSWD_PATH |
|||
value: /auth/htpasswd |
|||
volumeMounts: |
|||
- name: image-store |
|||
mountPath: /var/lib/registry |
|||
- name: auth-dir |
|||
mountPath: /auth |
|||
ports: |
|||
- containerPort: 5000 |
|||
name: registry |
|||
protocol: TCP |
|||
volumes: |
|||
- name: image-store |
|||
emptyDir: {} |
|||
- name: auth-dir |
|||
secret: |
|||
secretName: registry-auth-secret |
@ -1,81 +0,0 @@ |
|||
# Kube-Registry with GCS storage backend |
|||
|
|||
Besides local file system, docker registry also supports a number of cloud storage backends. Full list of supported backend can be found [here](https://docs.docker.com/registry/configuration/#storage). This document describes how to enable GCS for kube-registry as storage backend. |
|||
|
|||
A few preparation steps are needed. |
|||
1. Create a bucket named kube-registry in GCS. |
|||
1. Create a service account for GCS access and create key file in json format. Detail instruction can be found [here](https://cloud.google.com/storage/docs/authentication#service_accounts). |
|||
|
|||
|
|||
### Pack Keyfile into a Secret |
|||
|
|||
Assuming you have downloaded the keyfile as `keyfile.json`. Create secret with the `keyfile.json`... |
|||
```console |
|||
$ kubectl --namespace=kube-system create secret generic gcs-key-secret --from-file=keyfile=keyfile.json |
|||
``` |
|||
|
|||
|
|||
### Run Registry |
|||
|
|||
<!-- BEGIN MUNGE: EXAMPLE registry-gcs-rc.yaml --> |
|||
```yaml |
|||
apiVersion: v1 |
|||
kind: ReplicationController |
|||
metadata: |
|||
name: kube-registry-v0 |
|||
namespace: kube-system |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
template: |
|||
metadata: |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
containers: |
|||
- name: registry |
|||
image: registry:2 |
|||
resources: |
|||
# keep request = limit to keep this container in guaranteed class |
|||
limits: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
requests: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
env: |
|||
- name: REGISTRY_HTTP_ADDR |
|||
value: :5000 |
|||
- name: REGISTRY_STORAGE |
|||
value: gcs |
|||
- name: REGISTRY_STORAGE_GCS_BUCKET |
|||
value: kube-registry |
|||
- name: REGISTRY_STORAGE_GCS_KEYFILE |
|||
value: /gcs/keyfile |
|||
ports: |
|||
- containerPort: 5000 |
|||
name: registry |
|||
protocol: TCP |
|||
volumeMounts: |
|||
- name: gcs-key |
|||
mountPath: /gcs |
|||
volumes: |
|||
- name: gcs-key |
|||
secret: |
|||
secretName: gcs-key-secret |
|||
``` |
|||
<!-- END MUNGE: EXAMPLE registry-gcs-rc.yaml --> |
|||
|
|||
|
|||
No changes are needed for other components (kube-registry service and proxy). |
|||
|
|||
|
|||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/addons/registry/gcs/README.md?pixel)]() |
@ -1,52 +0,0 @@ |
|||
apiVersion: v1 |
|||
kind: ReplicationController |
|||
metadata: |
|||
name: kube-registry-v0 |
|||
namespace: kube-system |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
template: |
|||
metadata: |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
containers: |
|||
- name: registry |
|||
image: registry:2 |
|||
resources: |
|||
# keep request = limit to keep this container in guaranteed class |
|||
limits: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
requests: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
env: |
|||
- name: REGISTRY_HTTP_ADDR |
|||
value: :5000 |
|||
- name: REGISTRY_STORAGE |
|||
value: gcs |
|||
- name: REGISTRY_STORAGE_GCS_BUCKET |
|||
value: kube-registry |
|||
- name: REGISTRY_STORAGE_GCS_KEYFILE |
|||
value: /gcs/keyfile |
|||
ports: |
|||
- containerPort: 5000 |
|||
name: registry |
|||
protocol: TCP |
|||
volumeMounts: |
|||
- name: gcs-key |
|||
mountPath: /gcs |
|||
volumes: |
|||
- name: gcs-key |
|||
secret: |
|||
secretName: gcs-key-secret |
@ -0,0 +1,7 @@ |
|||
--- |
|||
apiVersion: v1 |
|||
kind: Namespace |
|||
metadata: |
|||
name: {{ registry_namespace }} |
|||
labels: |
|||
name: {{ registry_namespace }} |
@ -1,28 +1,33 @@ |
|||
--- |
|||
apiVersion: extensions/v1beta1 |
|||
apiVersion: apps/v1 |
|||
kind: DaemonSet |
|||
metadata: |
|||
name: kube-registry-proxy |
|||
namespace: {{ system_namespace }} |
|||
name: registry-proxy |
|||
namespace: {{ registry_namespace }} |
|||
labels: |
|||
k8s-app: kube-registry-proxy |
|||
k8s-app: registry-proxy |
|||
kubernetes.io/cluster-service: "true" |
|||
version: v{{ registry_proxy_image_tag }} |
|||
spec: |
|||
selector: |
|||
matchLabels: |
|||
k8s-app: registry-proxy |
|||
version: v{{ registry_proxy_image_tag }} |
|||
template: |
|||
metadata: |
|||
labels: |
|||
k8s-app: kube-registry-proxy |
|||
kubernetes.io/name: "kube-registry-proxy" |
|||
k8s-app: registry-proxy |
|||
kubernetes.io/name: "registry-proxy" |
|||
kubernetes.io/cluster-service: "true" |
|||
version: v{{ registry_proxy_image_tag }} |
|||
spec: |
|||
containers: |
|||
- name: kube-registry-proxy |
|||
- name: registry-proxy |
|||
image: {{ registry_proxy_image_repo }}:{{ registry_proxy_image_tag }} |
|||
imagePullPolicy: {{ k8s_image_pull_policy }} |
|||
env: |
|||
- name: REGISTRY_HOST |
|||
value: kube-registry.kube-system.svc.cluster.local |
|||
value: registry.{{ registry_namespace }}.svc.{{ cluster_name }} |
|||
- name: REGISTRY_PORT |
|||
value: "5000" |
|||
ports: |
@ -1,17 +0,0 @@ |
|||
kind: PersistentVolume |
|||
apiVersion: v1 |
|||
metadata: |
|||
name: kube-system-kube-registry-pv |
|||
labels: |
|||
kubernetes.io/cluster-service: "true" |
|||
addonmanager.kubernetes.io/mode: Reconcile |
|||
spec: |
|||
{% if pillar.get('cluster_registry_disk_type', '') == 'gce' %} |
|||
capacity: |
|||
storage: {{ pillar['cluster_registry_disk_size'] }} |
|||
accessModes: |
|||
- ReadWriteOnce |
|||
gcePersistentDisk: |
|||
pdName: "{{ pillar['cluster_registry_disk_name'] }}" |
|||
fsType: "ext4" |
|||
{% endif %} |
@ -1,14 +1,16 @@ |
|||
kind: PersistentVolumeClaim |
|||
--- |
|||
apiVersion: v1 |
|||
kind: PersistentVolumeClaim |
|||
metadata: |
|||
name: kube-registry-pvc |
|||
namespace: kube-system |
|||
name: registry-pvc |
|||
namespace: {{ registry_namespace }} |
|||
labels: |
|||
kubernetes.io/cluster-service: "true" |
|||
addonmanager.kubernetes.io/mode: Reconcile |
|||
spec: |
|||
accessModes: |
|||
- ReadWriteOnce |
|||
storageClassName: {{ registry_storage_class }} |
|||
resources: |
|||
requests: |
|||
storage: {{ pillar['cluster_registry_disk_size'] }} |
|||
storage: {{ registry_disk_size }} |
@ -1,41 +1,48 @@ |
|||
--- |
|||
apiVersion: v1 |
|||
kind: ReplicationController |
|||
apiVersion: apps/v1 |
|||
kind: ReplicaSet |
|||
metadata: |
|||
name: kube-registry-v{{ registry_image_tag }} |
|||
namespace: {{ system_namespace }} |
|||
name: registry-v{{ registry_image_tag }} |
|||
namespace: {{ registry_namespace }} |
|||
labels: |
|||
k8s-app: kube-registry-upstream |
|||
k8s-app: registry |
|||
version: v{{ registry_image_tag }} |
|||
kubernetes.io/cluster-service: "true" |
|||
addonmanager.kubernetes.io/mode: Reconcile |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
k8s-app: kube-registry-upstream |
|||
version: v{{ registry_image_tag }} |
|||
matchLabels: |
|||
k8s-app: registry |
|||
version: v{{ registry_image_tag }} |
|||
template: |
|||
metadata: |
|||
labels: |
|||
k8s-app: kube-registry-upstream |
|||
k8s-app: registry |
|||
version: v{{ registry_image_tag }} |
|||
kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
containers: |
|||
- name: registry |
|||
image: {{ registry_image_repo }}:{{ registry_image_tag }} |
|||
imagePullPolicy: {{ k8s_image_pull_policy }} |
|||
env: |
|||
- name: REGISTRY_HTTP_ADDR |
|||
value: :5000 |
|||
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY |
|||
value: /var/lib/registry |
|||
volumeMounts: |
|||
- name: image-store |
|||
- name: registry-pvc |
|||
mountPath: /var/lib/registry |
|||
ports: |
|||
- containerPort: 5000 |
|||
name: registry |
|||
protocol: TCP |
|||
volumes: |
|||
- name: image-store |
|||
- name: registry-pvc |
|||
{% if registry_storage_class != none %} |
|||
persistentVolumeClaim: |
|||
claimName: registry-pvc |
|||
{% else %} |
|||
emptyDir: {} |
|||
{% endif %} |
@ -1,116 +0,0 @@ |
|||
# Enable TLS for Kube-Registry |
|||
|
|||
This document describes how to enable TLS for kube-registry. Before you start, please check if you have all the prerequisite: |
|||
|
|||
- A domain for kube-registry. Assuming it is ` myregistrydomain.com`. |
|||
- Domain certificate and key. Assuming they are `domain.crt` and `domain.key` |
|||
|
|||
### Pack domain.crt and domain.key into a Secret |
|||
|
|||
```console |
|||
$ kubectl --namespace=kube-system create secret generic registry-tls-secret --from-file=domain.crt=domain.crt --from-file=domain.key=domain.key |
|||
``` |
|||
|
|||
### Run Registry |
|||
|
|||
Please be noted that this sample rc is using emptyDir as storage backend for simplicity. |
|||
|
|||
<!-- BEGIN MUNGE: EXAMPLE registry-tls-rc.yaml --> |
|||
```yaml |
|||
apiVersion: v1 |
|||
kind: ReplicationController |
|||
metadata: |
|||
name: kube-registry-v0 |
|||
namespace: kube-system |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
template: |
|||
metadata: |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
containers: |
|||
- name: registry |
|||
image: registry:2 |
|||
resources: |
|||
# keep request = limit to keep this container in guaranteed class |
|||
limits: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
requests: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
env: |
|||
- name: REGISTRY_HTTP_ADDR |
|||
value: :5000 |
|||
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY |
|||
value: /var/lib/registry |
|||
- name: REGISTRY_HTTP_TLS_CERTIFICATE |
|||
value: /certs/domain.crt |
|||
- name: REGISTRY_HTTP_TLS_KEY |
|||
value: /certs/domain.key |
|||
volumeMounts: |
|||
- name: image-store |
|||
mountPath: /var/lib/registry |
|||
- name: cert-dir |
|||
mountPath: /certs |
|||
ports: |
|||
- containerPort: 5000 |
|||
name: registry |
|||
protocol: TCP |
|||
volumes: |
|||
- name: image-store |
|||
emptyDir: {} |
|||
- name: cert-dir |
|||
secret: |
|||
secretName: registry-tls-secret |
|||
``` |
|||
<!-- END MUNGE: EXAMPLE registry-tls-rc.yaml --> |
|||
|
|||
### Expose External IP for Kube-Registry |
|||
|
|||
Modify the default kube-registry service to `LoadBalancer` type and point the DNS record of `myregistrydomain.com` to the service external ip. |
|||
|
|||
<!-- BEGIN MUNGE: EXAMPLE registry-tls-svc.yaml --> |
|||
```yaml |
|||
apiVersion: v1 |
|||
kind: Service |
|||
metadata: |
|||
name: kube-registry |
|||
namespace: kube-system |
|||
labels: |
|||
k8s-app: kube-registry |
|||
# kubernetes.io/cluster-service: "true" |
|||
kubernetes.io/name: "KubeRegistry" |
|||
spec: |
|||
selector: |
|||
k8s-app: kube-registry |
|||
type: LoadBalancer |
|||
ports: |
|||
- name: registry |
|||
port: 5000 |
|||
protocol: TCP |
|||
``` |
|||
<!-- END MUNGE: EXAMPLE registry-tls-svc.yaml --> |
|||
|
|||
### To Verify |
|||
|
|||
Now you should be able to access your kube-registry from another docker host. |
|||
```console |
|||
docker pull busybox |
|||
docker tag busybox myregistrydomain.com:5000/busybox |
|||
docker push myregistrydomain.com:5000/busybox |
|||
docker pull myregistrydomain.com:5000/busybox |
|||
``` |
|||
|
|||
|
|||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/addons/registry/tls/README.md?pixel)]() |
@ -1,57 +0,0 @@ |
|||
apiVersion: v1 |
|||
kind: ReplicationController |
|||
metadata: |
|||
name: kube-registry-v0 |
|||
namespace: kube-system |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
template: |
|||
metadata: |
|||
labels: |
|||
k8s-app: kube-registry |
|||
version: v0 |
|||
# kubernetes.io/cluster-service: "true" |
|||
spec: |
|||
containers: |
|||
- name: registry |
|||
image: registry:2 |
|||
resources: |
|||
# keep request = limit to keep this container in guaranteed class |
|||
limits: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
requests: |
|||
cpu: 100m |
|||
memory: 100Mi |
|||
env: |
|||
- name: REGISTRY_HTTP_ADDR |
|||
value: :5000 |
|||
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY |
|||
value: /var/lib/registry |
|||
- name: REGISTRY_HTTP_TLS_CERTIFICATE |
|||
value: /certs/domain.crt |
|||
- name: REGISTRY_HTTP_TLS_KEY |
|||
value: /certs/domain.key |
|||
volumeMounts: |
|||
- name: image-store |
|||
mountPath: /var/lib/registry |
|||
- name: cert-dir |
|||
mountPath: /certs |
|||
ports: |
|||
- containerPort: 5000 |
|||
name: registry |
|||
protocol: TCP |
|||
volumes: |
|||
- name: image-store |
|||
emptyDir: {} |
|||
- name: cert-dir |
|||
secret: |
|||
secretName: registry-tls-secret |
|||
|
@ -1,17 +0,0 @@ |
|||
apiVersion: v1 |
|||
kind: Service |
|||
metadata: |
|||
name: kube-registry |
|||
namespace: kube-system |
|||
labels: |
|||
k8s-app: kube-registry |
|||
# kubernetes.io/cluster-service: "true" |
|||
kubernetes.io/name: "KubeRegistry" |
|||
spec: |
|||
selector: |
|||
k8s-app: kube-registry |
|||
type: LoadBalancer |
|||
ports: |
|||
- name: registry |
|||
port: 5000 |
|||
protocol: TCP |
Write
Preview
Loading…
Cancel
Save