一、Nginx简介

Nginx是一个常见的Web容器,也能做负载均衡器、反向代理工具,本文只讲述其作为Web容器的使用方式。

二、安装Metrics Server

使用Helm安装

  1. helm repo add bitnami https://charts.bitnami.com/bitnami
  2. helm install nginx bitnami/nginx -n test

部署完成,控制台打印:

  1. NAME: nginx
  2. LAST DEPLOYED: Sun Nov 1 21:28:17 2020
  3. NAMESPACE: test
  4. STATUS: deployed
  5. REVISION: 1
  6. TEST SUITE: None
  7. NOTES:
  8. ** Please be patient while the chart is being deployed **
  9. NGINX can be accessed through the following DNS name from within your cluster:
  10. nginx.test.svc.cluster.local (port 80)
  11. To access NGINX from outside the cluster, follow the steps below:
  12. 1. Get the NGINX URL by running these commands:
  13. NOTE: It may take a few minutes for the LoadBalancer IP to be available.
  14. Watch the status with: 'kubectl get svc --namespace test -w nginx'
  15. export SERVICE_PORT=$(kubectl get --namespace test -o jsonpath="{.spec.ports[0].port}" services nginx)
  16. export SERVICE_IP=$(kubectl get svc --namespace test nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  17. echo "http://${SERVICE_IP}:${SERVICE_PORT}"

使用YAML安装