1.開啓相關參數
KUBE_API_ARGS="--service-node-port-range=30000-32767 --enable-swagger-ui=true --apiserver-count=3 --audit-log-maxage=30 --audit-log-maxbackup=3 --audit-log-maxsize=100 --audit-log-path=/var/log/k8s/audit.log --event-ttl=1h"
2.建立用戶,給cluster—admin角色,執行(kubectl create -f 「yaml文件名」)
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin
namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: ecdataapi
subjects:
- kind: ServiceAccount
name: ecdataapi
namespace: kube-system
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
3.獲取token
kubectl get secret -n kube-system|grep admin
kubectl describe secret 「上條命令執行結果(例:ecdataapi-token-9w7zj)」 -n kube-system
4. 拿到token後,postman(6.7.1)中
file>settings>General>ssl certficate verification關閉
5.獲取服務地址
kubectl cluster-info
獲取地址後複製地址到postman,將剛纔生成的token複製到Authorization>type>bearer-Token
6.訪問目標地址