snippets/old_snippets/k8s-reg-secret.en.md

31 lines
822 B
Markdown

---
title: "creating k8s registry secrets"
date: 2020-03-29T20:43:14+02:00
draft: false
snippet_types: ["kubernetes"]
---
Hosting side projects in kubernetes and using gitlab container registry? This
is the command I run to create the needed secret for the cluster to pull the
image:
```shell
$ kubectl create secret docker-registry cool-project-gitlab \
--docker-server=registry.gitlab.com \
--docker-username=gitlab+deploy-token-666666 \
--docker-password=xxxxxxxxxxxxxxxxxxxx \
--docker-email=xxxxxxxxx@xmail.com
```
Then in the deployment.yml use the gitlab registry image and newly created image
secret:
```yaml
containers:
image: registry.gitlab.com/btbtravis/cool-project:0.0.1
imagePullPolicy: IfNotPresent
name: cool-project-api
imagePullSecrets:
- name: cool-projects-gitlab
```