What are the differents to pull images from a private Gitlab registry

I have private registry that has an image that I want to pull from my Kubernetes cluster. In other words, I want to deploy this image in my k8s cluster.

There’s a number of ways to an image from a private registry.

  1. Create a Secret based on existing Docker credentials.

kubectl create secret docker-registry mygitlab-registry --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

Reference

The above method works and I can pull from the registry.

  1. Log into Docker and Create a Secret based on existing Docker credentials

This method works but I had to specify a deploy token called gitlab-deploy-token so that I can use the environment variables $CI_DEPLOY_USER and $CI_DEPLOY_PASSWORD

I’m wondering if it is possible to do use a secret that is created from the username and password only so that I don’t use docker. For example the Secret resource file would be something similar to below

apiVersion: v1
kind: Secret
metadata:
  name: mysecret
data:
  username: YWRtaW4=
  password: MWYyZDFlMmU2N2Rm

Reference 1

Reference 2