【原】二进制部署 k8s 1.18.3 (16)

然后修改 ingress 文件

apiVersion: extensions/v1beta1 kind: Ingress metadata: name: nginx annotations: # 注意这里要设置为您前面配置的 INGRESS_CLASS,比如:nginx-internal kubernetes.io/ingress.class: "<YOUR_INGRESS_CLASS>"

示例:

[root@centos7-nginx yaml]# kubectl apply -f ingress-internal.yaml ingress.extensions/ingress-nginx-dns-internal created [root@centos7-nginx yaml]# cat ingress-internal.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-nginx-dns-internal # namespace: default annotations: kubernetes.io/ingress.class: "nginx-internal" spec: rules: - host: ng-inter.5179.top http: paths: - path: / backend: serviceName: nginx-dns servicePort: 80 [root@centos7-nginx yaml]# kubectl get ingress NAME CLASS HOSTS ADDRESS PORTS AGE ingress-nginx-dns <none> ng.5179.top 10.10.10.131 80 47m ingress-nginx-dns-internal <none> ng-inter.5179.top 10.10.10.131,10.10.10.132 80 32s

在 nginx 的配置文件中增加

[root@centos7-nginx yaml]# cat /etc/nginx/conf.d/ng.conf upstream nginx-dns{ ip_hash; server 10.10.10.131:31511; server 10.10.10.132:31511; } upstream nginx-dns-inter{ ip_hash; server 10.10.10.131:40377; server 10.10.10.132:40377; } server { listen 80; server_name ng.5179.top; #access_log logs/host.access.log main; location / { root html; proxy_pass ; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; index index.html index.htm; } } server { listen 80; server_name ng-inter.5179.top; #access_log logs/host.access.log main; location / { root html; proxy_pass ; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; index index.html index.htm; } }

重启后添加本地解析,然后访问即可

[root@centos7-nginx yaml]# curl -I HTTP/1.1 200 OK Server: nginx/1.16.1 Date: Sun, 21 Jun 2020 09:07:12 GMT Content-Type: text/html Content-Length: 612 Connection: keep-alive Vary: Accept-Encoding Last-Modified: Tue, 26 May 2020 15:00:20 GMT ETag: "5ecd2f04-264" Accept-Ranges: bytes [root@centos7-nginx yaml]# curl -I HTTP/1.1 200 OK Server: nginx/1.16.1 Date: Sun, 21 Jun 2020 09:07:17 GMT Content-Type: text/html Content-Length: 612 Connection: keep-alive Vary: Accept-Encoding Last-Modified: Tue, 26 May 2020 15:00:20 GMT ETag: "5ecd2f04-264" Accept-Ranges: bytes 3.17 安装 prometheus-operator 3.17.1 下载安装

使用 prometheus-operator 进行安装.

地址如下https://github.com/coreos/kube-prometheus

根据 Readme.md 进行版本的选择,本次 k8s 安装的是 1.18 ,所以 prometheus 选的分支为 release-0.5

git clone https://github.com/coreos/kube-prometheus.git -b release-0.5 cd kube-prometheus # Create the namespace and CRDs, and then wait for them to be availble before creating the remaining resources kubectl create -f manifests/setup until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done kubectl create -f manifests/

为了远程访问方便,创建了 ingress

[root@uk8s-a ingress]# cat ingress-grafana.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-grafana namespace: monitoring annotations: kubernetes.io/ingress.class: "nginx" spec: rules: - host: grafana.5179.top http: paths: - path: / backend: serviceName: grafana servicePort: 3000 [root@uk8s-a ingress]# cat ingress-prometheus.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-prometheus namespace: monitoring annotations: kubernetes.io/ingress.class: "nginx" spec: rules: - host: prometheus.5179.top http: paths: - path: / backend: serviceName: prometheus-k8s servicePort: 9090 [root@uk8s-a ingress]# cat ingress-alertmanager.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-alertmanager namespace: monitoring annotations: kubernetes.io/ingress.class: "nginx" spec: rules: - host: alertmanager.5179.top http: paths: - path: / backend: serviceName: alertmanager-main servicePort: 9093

查看 ingress

[root@uk8s-a ingress]# kubectl get ingress -A NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE monitoring ingress-alertmanager <none> alertmanager.5179.top 192.168.0.170 80 3m6s monitoring ingress-grafana <none> grafana.5179.top 192.168.0.170 80 3m6s monitoring ingress-prometheus <none> prometheus.5179.top 192.168.0.170 80 3m6s 3.17.2 遇到的坑

【原】二进制部署 k8s 1.18.3

1) kube-scheduler和kube-controller-manager 的target 为 0/0

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzyxyd.html