当前位置:   article > 正文

Kubernetes1.21部署apisix网关_helm安装apisix

helm安装apisix

目录

1、安装nfs-subdir-external-provisioner

2、helm安装apisix

3、Prometheus使用kubesphere内置的

4、创建ServiceMonitor

5、安装Grafana   grafana.yaml kubectl apply -f grafana.yaml(参照官网)

6、配置Grafana ,添加Prometheus数据源

 7、部署whoami或者httpbin,配置网关,进行访问

8、创建Grafana Dashboard,选择import,效果如下

9、运行pod

 10、应用访问,加上gateway的端口号



1、安装nfs-subdir-external-provisioner

helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner  -f values.yaml     -n default

docker pull k8s.gcr.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2
下载地址nfs-subdir-external-provisioner安装文件资源-CSDN文库

2、helm安装apisix

helm repo add apisix https://charts.apiseven.com
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update

helm install apisix apisix/apisix  \
--set ingress-controller.enabled=true \
--set dashboard.enabled=true \
--set gateway.tls.enabled=true \
--set etcd.volumePermissions.enabled=true \
--set etcd.persistence.storageClass="nfs-client" \
--set etcd.persistence.size="22Gi" \
--set ingress-controller.config.apisix.adminKey="edd1c9f034335f136f87ad84b625c8f1" \
--set admin.credentials.admin="edd1c9f034335f136f87ad84b625c8f1" \
--set admin.credentials.viewer="4054f7cf07e344346cd3f287985e76a2" \
--set ingress-controller.config.apisix.serviceNamespace=apisix  --namespace apisix --create-namespace

安装完成,查看网关的打印地址

export NODE_PORT=$(kubectl get --namespace apisix -o jsonpath="{.spec.ports[0].nodePort}" services apisix-gateway)
export NODE_IP=$(kubectl get nodes --namespace apisix -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT

3、Prometheus使用kubesphere内置的

使用第二步安装的apisix service 端口未暴露,需要修改暴露出来

4、创建ServiceMonitor

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: apisix
  namespace: apisix
spec:
  endpoints:
    - scheme: http
      targetPort: monitor
      path: /apisix/prometheus/metrics
      interval: 15s
  namespaceSelector:
    matchNames:
      - apisix
  selector:
    matchLabels:
      app.kubernetes.io/name: apisix
      app.kubernetes.io/version: 3.3.0
      helm.sh/chart: apisix-2.0.0 

5、安装Grafana   grafana.yaml kubectl apply -f grafana.yaml(参照官网)

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: grafana-pvc
  namespace: apisix
spec:
  storageClassName: nfs-client
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: grafana
  name: grafana
  namespace: apisix
spec:
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      securityContext:
        fsGroup: 472
        supplementalGroups:
          - 0
      containers:
        - name: grafana
          image: grafana/grafana:9.1.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
              name: http-grafana
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /robots.txt
              port: 3000
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 2
          livenessProbe:
            failureThreshold: 3
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 3000
            timeoutSeconds: 1
          resources:
            requests:
              cpu: 250m
              memory: 750Mi
          volumeMounts:
            - mountPath: /var/lib/grafana
              name: grafana-pv
      volumes:
        - name: grafana-pv
          persistentVolumeClaim:
            claimName: grafana-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: grafana
  namespace: apisix
spec:
  ports:
    - port: 3000
      protocol: TCP
      targetPort: http-grafana
  selector:
    app: grafana
  sessionAffinity: None
  type: LoadBalancer

prometheus获取apisix的信息可能会初选拒绝连接的情况,默认apisix暴露的地址是本地的,需要修改下配置

 正常情况,看到信息应该如下图

6、配置Grafana ,添加Prometheus数据源

地址是:http://prometheus-operated.kubesphere-monitoring-system.svc:9090

 7、部署whoami或者httpbin,配置网关,进行访问

8、创建Grafana Dashboard,选择import,效果如下

 

9、运行pod

 10、应用访问,加上gateway的端口号

httpbin.org (liebe.com.cn)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/214092
推荐阅读
相关标签
  

闽ICP备14008679号