PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
627 stars 135 forks source link

How to depoy Rancher with nginx ingress controller?? #180

Closed yeranosyanvahan closed 2 years ago

yeranosyanvahan commented 2 years ago

Hello as title says I want to deploy rancher. Here is my directory structure

.
├── inventory.yaml
├── main.yaml
├── master
│   └── ingress.yaml
└── pods
    └── manifest.yaml

pods/manifest.yaml file

apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
  name: cert-manager
  namespace: cert-manager
spec:
  chart: jetstack/cert-manager
  repo: https://charts.jetstack.io
  targetNamespace: cert-manager
  version: v.1.5.1
---
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
  name: rancher
  namespace: cattle-system
spec:
  chart: rancher-stable/rancher
  repo: https://releases.rancher.com/server-charts/stable
  targetNamespace: cattle-system
  set:apiVersion: helm.cattle.io/v1

and master/ingress.yaml file

kind: HelmChart
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
spec:
  chart: ingress-nginx
  repo: https://kubernetes.github.io/ingress-nginx
  targetNamespace: ingress-nginx

and the playbook is main.yaml

---

- name: Building k3s cluster
  hosts: k3s_cluster
  vars:
    k3s_become: true
    k3s_server_pod_manifests_urls:
      - url: https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.crds.yaml
        filename: cert-manager.yaml
# how to deploy the rancher from pods/manifest.yaml
# how to replace ingress controller ???
  roles:
    - role: xanmanning.k3s
evilhamsterman commented 2 years ago

You will have to disable the Traefik ingress controller on deployment https://rancher.com/docs/k3s/latest/en/networking/#traefik-ingress-controller, which you can do in this role with the variable set like this

k3s_server:
  disable:
    - traefik

Then you will have to deploy your nginx controller using their instructions, usually helm. You can either do that manually or you could use the k3s_server_manifests_templates and k3s_server_manifests_urls to put the manifests on the controller. If you want to deploy with helm using the server manifest variables you can use the CRD provided by k3s which you can read about here https://rancher.com/docs/k3s/latest/en/helm/

xanmanning commented 2 years ago

Thanks @evilhamsterman

crutonjohn commented 2 years ago

I'm going to close this as it @evilhamsterman has answered how to accomplish this. if you need additional help or have a bug to report, please feel free to open another issue. Thanks!