# Migrating Docker Stack to Rancher RKE2 Kubernetes Cluster You may be comfortable operating with Portainer or `docker-compose`, but there comes a point where you might want to migrate those existing workloads to a Kubernetes cluster as easily-as-possible. Lucklily, there is a way to do this using a tool called "**Kompose**'. Follow the instructions seen below to convert and deploy your existing `docker-compose.yml` into a Kubernetes cluster such as Rancher RKE2. ## Installing Kompose The first step involves downloading Kompose from https://kompose.io/installation. Once you have it downloaded and installed onto your environment of choice, save a copy of your `docker-compose.yml` file somewhere on-disk, then open up a terminal and run the following command: ```sh kompose --file docker-compose.yaml convert --stdout > compose-k8s.yaml ``` This will attempt to convert the `docker-compose.yml` file into a Kubernetes manifest YAML file. The Before and after example can be seen below: === "docker-compose.yml`" ``` yaml version: "2.1" services: ntfy: image: binwiederhier/ntfy container_name: ntfy command: - serve environment: - NTFY_ATTACHMENT_CACHE_DIR=/var/lib/ntfy/attachments - NTFY_BASE_URL=https://ntfy.bunny-lab.io - TZ=America/Denver # optional: Change to your desired timezone #user: UID:GID # optional: Set custom user/group or uid/gid volumes: - /srv/containers/ntfy/cache:/var/cache/ntfy - /srv/containers/ntfy/etc:/etc/ntfy ports: - 80:80 restart: always networks: docker_network: ipv4_address: 192.168.5.45 networks: default: external: name: docker_network docker_network: external: true ``` === "compose-k8s.yaml" ``` yaml --- apiVersion: v1 kind: Service metadata: annotations: kompose.cmd: C:\ProgramData\chocolatey\lib\kubernetes-kompose\tools\kompose.exe --file ntfy.yaml convert --stdout kompose.version: 1.37.0 (fb0539e64) labels: io.kompose.service: ntfy name: ntfy spec: ports: - name: "80" port: 80 targetPort: 80 selector: io.kompose.service: ntfy --- apiVersion: apps/v1 kind: Deployment metadata: annotations: kompose.cmd: C:\ProgramData\chocolatey\lib\kubernetes-kompose\tools\kompose.exe --file ntfy.yaml convert --stdout kompose.version: 1.37.0 (fb0539e64) labels: io.kompose.service: ntfy name: ntfy spec: replicas: 1 selector: matchLabels: io.kompose.service: ntfy strategy: type: Recreate template: metadata: annotations: kompose.cmd: C:\ProgramData\chocolatey\lib\kubernetes-kompose\tools\kompose.exe --file ntfy.yaml convert --stdout kompose.version: 1.37.0 (fb0539e64) labels: io.kompose.service: ntfy spec: containers: - args: - serve env: - name: NTFY_ATTACHMENT_CACHE_DIR value: /var/lib/ntfy/attachments - name: NTFY_BASE_URL value: https://ntfy.bunny-lab.io - name: TZ value: America/Denver image: binwiederhier/ntfy name: ntfy ports: - containerPort: 80 protocol: TCP volumeMounts: - mountPath: /var/cache/ntfy name: ntfy-claim0 - mountPath: /etc/ntfy name: ntfy-claim1 restartPolicy: Always volumes: - name: ntfy-claim0 persistentVolumeClaim: claimName: ntfy-claim0 - name: ntfy-claim1 persistentVolumeClaim: claimName: ntfy-claim1 --- apiVersion: v1 kind: PersistentVolumeClaim metadata: labels: io.kompose.service: ntfy-claim0 name: ntfy-claim0 spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Mi --- apiVersion: v1 kind: PersistentVolumeClaim metadata: labels: io.kompose.service: ntfy-claim1 name: ntfy-claim1 spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Mi ```