All Projects → jugatsu → gitlab-registry-kubernetes-secrets-howto

jugatsu / gitlab-registry-kubernetes-secrets-howto

Licence: other
How to use Gitlab Container Registry with Kubernetes.

Projects that are alternatives of or similar to gitlab-registry-kubernetes-secrets-howto

gitrows
A lightweight module for using git as a database
Stars: ✭ 212 (+606.67%)
Mutual labels:  gitlab
app
Aplus Framework App Project
Stars: ✭ 338 (+1026.67%)
Mutual labels:  gitlab
munin-plugins-gitlab
Munin-plugins for monitoring a GitLab instance
Stars: ✭ 27 (-10%)
Mutual labels:  gitlab
epf-transmitter
astrizhachuk.github.io/epf-transmitter/
Stars: ✭ 32 (+6.67%)
Mutual labels:  gitlab
vim-gitlab
vim-gitlab is a vim client for GitLab
Stars: ✭ 17 (-43.33%)
Mutual labels:  gitlab
gitlab-ci-android-fastlane
Docker image for building android apps on Gitlab CI
Stars: ✭ 25 (-16.67%)
Mutual labels:  gitlab
code-examples-manager
Software tool to manage your notes and code examples, to publish them as gists or snippets
Stars: ✭ 26 (-13.33%)
Mutual labels:  gitlab
shards-info
Source code of https://shards.info/
Stars: ✭ 32 (+6.67%)
Mutual labels:  gitlab
nebulous
The Kubefirst Open Source Platform
Stars: ✭ 122 (+306.67%)
Mutual labels:  gitlab
gitlab-panorama
Visualize the latest pipeline-states for your repositories and branches
Stars: ✭ 24 (-20%)
Mutual labels:  gitlab
sonar-auth-gitlab-plugin
Use GitLab OAuth login in SonarQube login page
Stars: ✭ 97 (+223.33%)
Mutual labels:  gitlab
froggit-go
Froggit-Go is a universal Go library, allowing to perform actions on VCS providers.
Stars: ✭ 19 (-36.67%)
Mutual labels:  gitlab
Attribouter
A lightweight "about screen" library to allow quick but customizable attribution in Android apps.
Stars: ✭ 117 (+290%)
Mutual labels:  gitlab
grru
Gitlab Release Remover UI
Stars: ✭ 42 (+40%)
Mutual labels:  gitlab
autoload
Aplus Framework Autoload Library
Stars: ✭ 18 (-40%)
Mutual labels:  gitlab
rhythm
Time-based job scheduler for Apache Mesos
Stars: ✭ 30 (+0%)
Mutual labels:  gitlab
gitlab-project-export
Simple python project for exporting GitLab projects with Export Project funkcionality in GitLab API. Import of exported projects is also supported
Stars: ✭ 69 (+130%)
Mutual labels:  gitlab
hej
Hej! is a simple authentication boilerplate for Socialite.
Stars: ✭ 111 (+270%)
Mutual labels:  gitlab
gitlab-chart
Kubernetes Helm chart to deploy GitLab
Stars: ✭ 59 (+96.67%)
Mutual labels:  gitlab
godot-cpp-ci
Docker image and Github Actions to automatically compile Godot C++ GDNative libraries.
Stars: ✭ 21 (-30%)
Mutual labels:  gitlab

Description

Copy-Paste Ready™ how-to for using private Gitlab Container Registry with Kubernetes.

ref: https://gist.github.com/rkuzsma/b9a0e342c56479f5e58d654b1341f01e

Copy and edit example env file accordingly

cp dockercfg.env.example dockercfg.env

Export variables from dockercfg.env

eval $(cat dockercfg.env)

Export additional variables

export REGISTRY_NAME=`echo $DOCKER_REGISTRY_SERVER | sed -e 's/^http:\/\///g' -e 's/^https:\/\///g'`
export DOCKER_IMAGE_FULL_PATH=$REGISTRY_NAME/$DOCKER_IMAGE_PATH

Create secret in the Kubernetes Cluster

kubectl create secret docker-registry gitlab-registry \
  --docker-server=$DOCKER_REGISTRY_SERVER \
  --docker-username=$DOCKER_USER \
  --docker-password=$DOCKER_PASSWORD \
  --docker-email=$DOCKER_EMAIL

Test

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: foo
spec:
  containers:
    - name: foo
      image: $DOCKER_IMAGE_FULL_PATH
      imagePullPolicy: Always
  imagePullSecrets:
    - name: gitlab-registry
EOF

Check if the image was pulled successfully

kubectl describe po/foo | grep -i pull

Cleanup

Remove pod

kubectl delete po/foo

Remove file with environment variables

rm dockercfg.env

Unset environment variables

unset DOCKER_REGISTRY_SERVER
unset DOCKER_USER
unset DOCKER_EMAIL
unset DOCKER_PASSWORD
unset DOCKER_IMAGE_PATH
unset REGISTRY_NAME
unset DOCKER_IMAGE_FULL_PATH

Sharing the secret across multiple Kubernetes namespaces 🎉

export NAMESPACE=gitlab
kubectl get secret gitlab-registry -o yaml \
  | sed "s/default/$NAMESPACE/g" \
  | kubectl -n $NAMESPACE create -f -
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].