Logo

Flagger 安装

学习如何在 Kubernetes 集群上安装 Flagger。

概念

Flagger 安装

学习如何在 Kubernetes 集群上安装 Flagger。

...
1k3d cluster create -p"80:80" mycluster

创建 K3s 集群命令的输出

1INFO[0000] portmapping '80:80' lacks a nodefilter, but there's more than one node: defaulting to [servers:*:proxy agents:*:proxy] 2INFO[0000] Prep: Network 3INFO[0000] Created network 'k3d-mycluster' 4INFO[0000] Created volume 'k3d-mycluster-images' 5INFO[0000] Starting new tools node... 6INFO[0001] Creating node 'k3d-mycluster-server-0' 7INFO[0002] Pulling image 'docker.io/rancher/k3d-tools:5.0.0' 8INFO[0002] Pulling image 'docker.io/rancher/k3s:v1.21.5-k3s1' 9INFO[0020] Starting Node 'k3d-mycluster-tools' 10INFO[0037] Creating LoadBalancer 'k3d-mycluster-serverlb' 11INFO[0037] Pulling image 'docker.io/rancher/k3d-proxy:5.0.0' 12INFO[0043] Using the k3d-tools node to gather environment information 13INFO[0043] HostIP: using network gateway... 14INFO[0043] Starting cluster 'mycluster' 15INFO[0043] Starting servers... 16INFO[0044] Starting Node 'k3d-mycluster-server-0' 17INFO[0044] Deleted k3d-mycluster-tools 18INFO[0055] Starting agents... 19INFO[0055] Starting helpers... 20INFO[0056] Starting Node 'k3d-mycluster-serverlb' 21INFO[0064] Injecting record '172.19.0.1 host.k3d.internal'... 22INFO[0069] Cluster 'mycluster' created successfully! 23INFO[0069] --kubeconfig-update-default=false --> sets --kubeconfig-switch-context=false 24INFO[0069] You can now use it like this: 25kubectl config use-context k3d-mycluster 26kubectl cluster-info
1curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 2chmod 700 get_helm.sh 3./get_helm.sh

安装 Helm 命令的输出

1Downloading https://get.helm.sh/helm-v3.10.1-linux-amd64.tar.gz 2Verifying checksum... Done. 3Preparing to install helm into /usr/local/bin 4helm installed into /usr/local/bin/helm
1# 添加包含 Ingress 控制器图表的 Helm 仓库 2helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx 3 4# 创建 Ingress 控制器使用的命名空间 5kubectl create ns ingress-nginx 6 7# 在命名空间中安装 Ingress 控制器 8helm upgrade -i ingress-nginx ingress-nginx/ingress-nginx \ 9--namespace ingress-nginx \ 10--set controller.metrics.enabled=true \ 11--set controller.podAnnotations."prometheus\.io/scrape"=true \ 12--set controller.podAnnotations."prometheus\.io/port"=10254

安装 Ingress 控制器命令的输出

1helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx 2namespace/ingress-nginx created 3Release "ingress-nginx" does not exist. Installing it now. 4NAME: ingress-nginx 5LAST DEPLOYED: Sun Oct 23 15:30:22 2022 6NAMESPACE: ingress-nginx 7STATUS: deployed 8REVISION: 1 9TEST SUITE: None 10NOTES: 11The ingress-nginx controller has been installed. 12It may take a few minutes for the LoadBalancer IP to be available. 13You can watch the status by running 'kubectl --namespace ingress-nginx get services -o wide -w ingress-nginx-controller' 14 15An example Ingress that makes use of the controller: 16 apiVersion: networking.k8s.io/v1 17 kind: Ingress 18 metadata: 19 name: example 20 namespace: foo 21 spec: 22 ingressClassName: nginx 23 rules: 24 - host: www.example.com 25 http: 26 paths: 27 - pathType: Prefix 28 backend: 29 service: 30 name: exampleService 31 port: 32 number: 80 33 path: / 34 # This section is only required if TLS is to be enabled for the Ingress 35 tls: 36 - hosts: 37 - www.example.com 38 secretName: example-tls 39 40If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided: 41 42 apiVersion: v1 43 kind: Secret 44 metadata: 45 name: example-tls 46 namespace: foo 47 data: 48 tls.crt: <base64 encoded cert> 49 tls.key: <base64 encoded key> 50 type: kubernetes.io/tls
1# 添加包含 Flagger 图表的 Helm 仓库 2helm repo add flagger https://flagger.app 3 4# 在 ingress-nginx 命名空间中安装 Flagger 5helm upgrade -i flagger flagger/flagger \ 6--namespace ingress-nginx \ 7--set prometheus.install=true \ 8--set meshProvider=nginx

安装 Flagger 命令的输出

1"flagger" has been added to your repositories 2Release "flagger" does not exist. Installing it now. 3NAME: flagger 4LAST DEPLOYED: Sun Oct 23 15:31:41 2022 5NAMESPACE: ingress-nginx 6STATUS: deployed 7REVISION: 1 8TEST SUITE: None 9NOTES: 10Flagger installed
1helm upgrade -i flagger-loadtester flagger/loadtester

运行负载测试工具命令的输出

1Release "flagger-loadtester" does not exist. Installing it now. 2NAME: flagger-loadtester 3LAST DEPLOYED: Sun Oct 23 15:32:11 2022 4NAMESPACE: default 5STATUS: deployed 6REVISION: 1 7TEST SUITE: None 8NOTES: 9Flagger's load testing service is available at http://flagger-loadtester.default/
1kubectl get services -n ingress-nginx

检查 Ingress 控制器命令的输出

1NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE 2ingress-nginx-controller-admission ClusterIP 10.43.94.6 <none> 443/TCP 82s 3ingress-nginx-controller-metrics ClusterIP 10.43.156.60 <none> 10254/TCP 81s 4ingress-nginx-controller LoadBalancer 10.43.212.111 172.19.0.3 80:32634/TCP,443:32352/TCP 81s 5flagger-prometheus ClusterIP 10.43.223.36 <none> 9090/TCP 32s
Terminal

总结