项目作者: cloud-native-playgrounds

项目描述 :
Demonstrating how to setup Traefik on a k3s cluster using arkade and k3d.
高级语言:
项目地址: git://github.com/cloud-native-playgrounds/traefik-playground.git
创建时间: 2020-08-08T06:42:41Z
项目社区:https://github.com/cloud-native-playgrounds/traefik-playground

开源协议:MIT License

下载


traefik-playground

Demonstrating how to setup Traefik on a k3s cluster using arkade and k3d.

This is just a learning playground

Install k3d

k3d is a little helper to run k3s in docker, where k3s is the lightweight Kubernetes distribution by Rancher. It actually removes millions of lines of code from k8s. If you just need a learning playground, k3s is definitely your choice.

Check out k3d Github Page to see the installation guide.

When creating a cluster, k3d utilises kubectl and kubectl is not part of k3d. If you don’t have kubectl, please install and set up here.

Once you’ve installed k3d and kubectl, run

  1. k3d create -n traefik-playground
  1. INFO[0000] Created cluster network with ID 9f3c0c8caf0712b7f59970afd3c5db8159362b6ea34c84788f57b8e41a9011b3
  2. INFO[0000] Created docker volume k3d-traefik-playground-images
  3. INFO[0000] Creating cluster [traefik-playground]
  4. INFO[0000] Creating server using docker.io/rancher/k3s:v1.0.1...
  5. INFO[0004] SUCCESS: created cluster [traefik-playground]
  6. INFO[0004] You can now use the cluster with:
  7. export KUBECONFIG="$(k3d get-kubeconfig --name='traefik-playground')"
  8. kubectl cluster-info

Run k3d list to make sure the status is running.

  1. +--------------------+------------------------------+---------+---------+
  2. | NAME | IMAGE | STATUS | WORKERS |
  3. +--------------------+------------------------------+---------+---------+
  4. | traefik-playground | docker.io/rancher/k3s:v1.0.1 | running | 0/0 |
  5. +--------------------+------------------------------+---------+---------+

We need to make kubectl to use the kubeconfig for that cluster.

  1. export KUBECONFIG="$(k3d get-kubeconfig --name='traefik-playground')"

Install arkade

Moving on to arkade, it provides a simple Golang CLI with strongly-typed flags to install charts and apps to your cluster in one command. Originally, the codebase is derived from k3sup which I’ve contributed last month.

  1. curl -sLS https://dl.get-arkade.dev | sudo sh

Once you’ve installed it, you should see the following

  1. New version of arkade installed to /usr/local/bin
  2. _ _
  3. __ _ _ __| | ____ _ __| | ___
  4. / _` | '__| |/ / _` |/ _` |/ _ \
  5. | (_| | | | < (_| | (_| | __/
  6. \__,_|_| |_|\_\__,_|\__,_|\___|
  7. Get Kubernetes apps the easy way
  8. Version: 0.2.2
  9. Git Commit: 9063b6eb16deae5978805f71b0e749828c815490

arkade currently does not support non-existing namespace for traefik. Create the namespace first.

  1. kubectl create namespace traefik-playground

Install Traefik with dashboard via arkade. You can use an alias ark or arkade.

  1. arkade install traefik2 --dashboard -n traefik-playground
  1. Using kubeconfig: /Users/wingkwong/.config/k3d/traefik-playground/kubeconfig.yaml
  2. Client: "Darwin"
  3. "traefik" has been added to your repositories
  4. Hang tight while we grab the latest from your chart repositories...
  5. ...Successfully got an update from the "traefik" chart repository
  6. ...Successfully got an update from the "openfaas" chart repository
  7. ...Successfully got an update from the "stable" chart repository
  8. Update Complete. Happy Helming!⎈
  9. VALUES values.yaml
  10. Command: /Users/wingkwong/.arkade/bin/helm3/helm [upgrade --install traefik traefik/traefik --namespace traefik-playground --values /var/folders/v3/24stf97d7nv35j_9vwppqzy00000gp/T/charts/traefik/values.yaml --set service.type=LoadBalancer --set additional.checkNewVersion=false --set additional.sendAnonymousUsage=false --set dashboard.ingressRoute=true --set additionalArguments={--providers.kubernetesingress}]
  11. Release "traefik" does not exist. Installing it now.
  12. NAME: traefik
  13. LAST DEPLOYED: Mon Apr 20 17:41:21 2020
  14. NAMESPACE: traefik-playground
  15. STATUS: deployed
  16. REVISION: 1
  17. TEST SUITE: None
  18. =======================================================================
  19. = traefik2 has been installed =
  20. =======================================================================
  21. Thanks for using arkade!# Get started at: https://docs.traefik.io/v2.0/
  22. # Install with an optional dashboard
  23. arkade install traefik2 --dashboard
  24. # Find your LoadBalancer IP:
  25. kubectl get svc -n kube-system traefik

Check out the traefik service

  1. kubectl get svc -n traefik-playground traefik

Forwarding from [::1]:8082 -> 8080

  1. kubectl port-forward svc/traefik 8082:80 -n traefik-playground &

Currently there are some issues with the dashboard. Reported to arkade team and pending for a fix.

Clean up

  1. k3d delete -n traefik-playground