0. Establish a connection to your K3s cluster:

On the K3s master node, run:

```
more /etc/rancher/k3s/k3s.yaml
```

Copy the contents to ../k3s/config
Export the KUBECONFIG environment variable:

```
export KUBECONFIG=../k3s/config
```

1. Create a new secret containing the credentials to access your GitLab registry:

```
kubectl create secret docker-registry gitlab-registry \
  --docker-server=registry.gitlab.ost.ch:45023 \
  --docker-username=<YOUR_USERNAME> \
  --docker-password=<YOUR_PASSWORD> \
  --docker-email=<YOUR_EMAIL>
```

Replace `<YOUR_USERNAME>`, `<YOUR_PASSWORD>`, and `<YOUR_EMAIL>` with your GitLab credentials.

2. Verify that the secret was created successfully:

```
kubectl get secret gitlab-registry --output=yaml
```

3. Create a Kubernetes deployment that uses the secret to pull the image from the GitLab registry:

```
kubectl create deployment rails-app --image=registry.gitlab.ost.ch:45023/dsys-instragramclone/nix-k3s-rook-mysql-rails:rails --replicas=1 --dry-run=client -o yaml > deployment.yaml
```

This will create a deployment manifest in the `deployment.yaml` file. Edit it to add the secret in the next step.

1. Edit the `deployment.yaml` file to add the `imagePullSecrets` field under `spec.template.spec`:

```
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: rails-app
  name: rails-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: rails-app
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: rails-app
    spec:
      containers:
      - image: registry.gitlab.ost.ch:45023/dsys-instragramclone/nix-k3s-rook-mysql-rails:rails
        name: nix-k3s-rook-mysql-rails
        resources: {}
      imagePullSecrets:
      - name: gitlab-registry
status: {}
```

Save the file after making the changes.

5. Apply the deployment manifest:

```
kubectl apply -f deployment.yaml
```

6. Create a Kubernetes service to expose the deployment:

```
kubectl expose deployment rails-app --type=LoadBalancer --port=80 --target-port=3000 --name=rails-app-lb
```

7. Verify that the service was created successfully:

```
kubectl get service rails-app-lb
```

This should return an external IP address that you can use to access the Rails app.
