---

- name: create persistent volume resources
  kubernetes.core.k8s:
    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
    state: "{{apps.dkregistry.state}}"
    definition: "{{ lookup('template', item) | from_yaml }}"
  loop:
    - dkregistry/pv.yaml
    - dkregistry/pv-claim.yaml
    - dkregistry/pv-auth.yaml
    - dkregistry/pv-auth-claim.yaml
  become: true

- name: create secret for dkregistry
  kubernetes.core.k8s:
    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
    state: "{{apps.dkregistry.state}}"
    definition:
      apiVersion: v1
      kind: Secret
      type: Opaque
      metadata:
        name: auth-secret-2025
        namespace: "{{apps.dkregistry.namespace}}"
      stringData:
        htpasswd: "richard:$2y$05$E7B3.iHmoLLSyFZJJWEj3u6eMdm2gPGBu1vAn7VPo9Axk3Wbict2m"
  become: true

- name: create docker-registry resources
  kubernetes.core.k8s:
    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
    state: "{{apps.dkregistry.state}}"
    definition: "{{ lookup('template', item) | from_yaml }}"
  loop:
#    - dkregistry/configmap.yaml
    - dkregistry/ingress.yaml
    - dkregistry/service.yaml
    - dkregistry/deployment.yaml
  become: true

