From 04ca2c39118e95b62740d1e7f1c99a03eb2edc8e Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Sat, 28 Jan 2023 15:34:04 +0100 Subject: [PATCH] Creado MiRegistry y probado en Nginx --- ...ivateDockerRegistryasaPodinKubernetes.html | 3455 +++++++++++++++++ MiRegistry/prueba.sh | 2 + MiRegistry/step-01.sh | 1 + MiRegistry/step-02.sh | 4 + MiRegistry/step-03.sh | 2 + MiRegistry/step-04.sh | 2 + MiRegistry/step-05.sh | 2 + MiRegistry/step-06.sh | 2 + MiRegistry/step-07.sh | 3 + Nginx/miweb-deployment.yaml | 5 +- 10 files changed, 3477 insertions(+), 1 deletion(-) create mode 100755 MiRegistry/DeployYourPrivateDockerRegistryasaPodinKubernetes.html create mode 100644 MiRegistry/prueba.sh create mode 100644 MiRegistry/step-02.sh create mode 100644 MiRegistry/step-03.sh create mode 100644 MiRegistry/step-04.sh create mode 100644 MiRegistry/step-05.sh create mode 100644 MiRegistry/step-06.sh create mode 100644 MiRegistry/step-07.sh diff --git a/MiRegistry/DeployYourPrivateDockerRegistryasaPodinKubernetes.html b/MiRegistry/DeployYourPrivateDockerRegistryasaPodinKubernetes.html new file mode 100755 index 00000000..ff3d3b5b --- /dev/null +++ b/MiRegistry/DeployYourPrivateDockerRegistryasaPodinKubernetes.html @@ -0,0 +1,3455 @@ + + + + + Deploy Your Private Docker Registry as a Pod in Kubernetes | by Varun Kumar G | The Startup | + Medium + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+
+
+ + + + + + + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
Published in
+
+

The Startup

+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+

+ Deploy Your Private Docker Registry as a Pod + in Kubernetes

+
+
+
+
+ + + + + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + +
+
+
+
+

--

+
+
+
+
+
+
+
+ + + + + +
+
+
+
+

--

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+

Get smarter at building your thing. + Follow to join The Startup’s +8 million monthly readers + & +760K followers.

+
+
+
+
+
+ + +
+
+
+
+
+
+ + + + +
+ +

Get the Medium app

+
+
A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
+ A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MiRegistry/prueba.sh b/MiRegistry/prueba.sh new file mode 100644 index 00000000..2a89d6a9 --- /dev/null +++ b/MiRegistry/prueba.sh @@ -0,0 +1,2 @@ + +kubectl run nginx-pod --image=docker-registry:32000/minginx:2.0 --overrides='{ "apiVersion": "v1", "spec": { "imagePullSecrets": [{"name": "reg-cred-secret"}] } }' diff --git a/MiRegistry/step-01.sh b/MiRegistry/step-01.sh index b451572c..b0e561b4 100644 --- a/MiRegistry/step-01.sh +++ b/MiRegistry/step-01.sh @@ -1,3 +1,4 @@ +# Crear certifidado TLS # mkdir -p /registry && cd "$_" # mkdir certs openssl req -x509 -newkey rsa:4096 -days 365 -nodes -sha256 -keyout certs/tls.key -out certs/tls.crt -subj "/CN=docker-registry" -addext "subjectAltName = DNS:docker-registry" diff --git a/MiRegistry/step-02.sh b/MiRegistry/step-02.sh new file mode 100644 index 00000000..85392907 --- /dev/null +++ b/MiRegistry/step-02.sh @@ -0,0 +1,4 @@ +# Crear htpasswd para autenticación de usuario +sudo docker run --rm --entrypoint htpasswd registry:2.6.2 -Bbn creylopez Rey-1176 + +echo "Copia la salida y pegala en /registry/auth/htpasswd" diff --git a/MiRegistry/step-03.sh b/MiRegistry/step-03.sh new file mode 100644 index 00000000..9fbb6502 --- /dev/null +++ b/MiRegistry/step-03.sh @@ -0,0 +1,2 @@ +# creando un secret +kubectl create secret tls certs-secret --cert=/registry/certs/tls.crt --key=/registry/certs/tls.key diff --git a/MiRegistry/step-04.sh b/MiRegistry/step-04.sh new file mode 100644 index 00000000..f0686964 --- /dev/null +++ b/MiRegistry/step-04.sh @@ -0,0 +1,2 @@ +# Create auth-secret +kubectl create secret generic auth-secret --from-file=/registry/auth/htpasswd diff --git a/MiRegistry/step-05.sh b/MiRegistry/step-05.sh new file mode 100644 index 00000000..8b7f2acb --- /dev/null +++ b/MiRegistry/step-05.sh @@ -0,0 +1,2 @@ +# persistent volume +kubectl apply -f registry-pv.yaml diff --git a/MiRegistry/step-06.sh b/MiRegistry/step-06.sh new file mode 100644 index 00000000..35f19ba6 --- /dev/null +++ b/MiRegistry/step-06.sh @@ -0,0 +1,2 @@ +# Crea el pod +kubectl create -f registry-deployment.yaml diff --git a/MiRegistry/step-07.sh b/MiRegistry/step-07.sh new file mode 100644 index 00000000..2ab88979 --- /dev/null +++ b/MiRegistry/step-07.sh @@ -0,0 +1,3 @@ +# crear secret con el usuario y la clave + +kubectl create secret docker-registry reg-cred-secret --docker-server=docker-registry:32000 --docker-username=creylopez --docker-password=Rey-1176 diff --git a/Nginx/miweb-deployment.yaml b/Nginx/miweb-deployment.yaml index 3e979b8c..8d5fb5da 100644 --- a/Nginx/miweb-deployment.yaml +++ b/Nginx/miweb-deployment.yaml @@ -47,7 +47,8 @@ spec: spec: containers: - name: nginx - image: linuxserver/nginx + #image: linuxserver/nginx + image: docker-registry:32000/minginx:2.0 #image: httpd ports: - containerPort: 80 @@ -57,6 +58,8 @@ spec: #mountPath: /config/www mountPath: /config #mountPath: /usr/local/apache2/htdocs + imagePullSecrets: + - name: reg-cred-secret volumes: - name: nginx-www-folder persistentVolumeClaim: