Unable to deploy using gitlabktl

Hello,

I have be trying to get a simple Serverless ci/cd working for past few days.

After resolving quite a few issues and looking at the gitlabktl code (GitLab.org / gitlabktl · GitLab), I have manages to get to this config:

image: golang:latest

variables:
  NAMESPACE: company.com/infrastructure/security/authentication

stages:
  - test
  - build
  - deploy

test:
  stage: test
  script:
    - mkdir -p $GOPATH/src/$(dirname $NAMESPACE)
    - ln -svf $CI_PROJECT_DIR $GOPATH/src/$NAMESPACE
    - cd $GOPATH/src/$NAMESPACE
    - go get -u github.com/golang/dep/cmd/dep
    - dep ensure --vendor-only
    - go fmt $(go list ./... | grep -v /vendor/)
    - go vet $(go list ./... | grep -v /vendor/)
    - go test -race $(go list ./... | grep -v /vendor/)
  only:
    refs:
      - branches
      - tags

build:
  stage: build
  image: docker:git
  services:
    - docker:dind
  script:
    - version
    - build
  artifacts:
    paths:
      - .version
  only:
    refs:
      - branches
      - tags

deploy:staging:
  stage: deploy
  image: registry.gitlab.com/gitlab-org/gitlabktl:latest
  script:
    - deploy
  environment:
    name: staging
  only:
    refs:
      - branches
      - tags

# ---------------------------------------------------------------------------

.auto_devops: &auto_devops |
  export K8S_NAMESPACE="security-$CI_ENVIRONMENT_SLUG"
  if [ "$CI_ENVIRONMENT_SLUG" == "prod" ]; then
    export K8S_NAMESPACE="security"
  fi

  function version() {
    export VERSION=$(git describe --always)
    export VERSION="${VERSION/-g/.}"
    export VERSION="${VERSION/v-/.}"
    export VERSION="${VERSION/v/.}"
    
    echo "****************************************"
    echo "** VER --> $VERSION"
    echo "****************************************"
    
    export CONTAINER_IMAGE="$CI_REGISTRY_IMAGE:$VERSION"
    echo $VERSION > .version
  }

  function build() {
    echo "Building Docker image..."
    docker build -t $CONTAINER_IMAGE .

    if [[ -n "$CI_REGISTRY_USER" ]]; then
      echo "Logging to GitLab container registry with CI credentials..."
      docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
      echo ""
    fi

    echo "Pushing to GitLab container registry..."
    docker push "$CONTAINER_IMAGE"
    echo ""
  }

  function deploy() {
    /usr/bin/gitlabktl app deploy \
      --name authentication \
      --kubeconfig $KUBECONFIG \
      --image $CI_REGISTRY_IMAGE \
      --registry-username $CI_REGISTRY_USER \
      --registry-password $CI_REGISTRY_PASSWORD \
      --tag $(cat .version)
  }

before_script:
  - *auto_devops

However, I am not able to make any further progress as I keep getting this error:

Welcome to GitLab CLI tool
time="2019-08-11T23:35:11Z" level=info msg="using registry" registry=registry.gitlab.com
time="2019-08-11T23:35:11Z" level=info msg="deploying registry credentials"
time="2019-08-11T23:35:12Z" level=fatal msg="could not deploy registry credentials" error=Unauthorized

I would really appreciate any help I can get here.

Thanks!