Helm 安装Nginx Ingress
为了便于将集群中的服务暴露到集群外部,需要使用Ingress。接下来使用Helm将Nginx Ingress部署到Kubernetes上。 Nginx Ingress Controller被部署在Kubernetes的边缘节点上。
这里将master
作为边缘节点,打上label
[root@master /]# kubectl label node master node-role.kubernetes.io/edge=
node/master labeled
[root@master /]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready edge,master 4d3h v1.15.1
slaver1 Ready <none> 4d2h v1.15.1
slaver2 Ready <none> 4d2h v1.15.1
安装
使用yaml
配置文件安装
stable/nginx-ingress chart的值文件ingress-nginx.yaml如下:
controller:
replicaCount: 1
hostNetwork: true
nodeSelector:
node-role.kubernetes.io/edge: ''
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- nginx-ingress
- key: component
operator: In
values:
- controller
topologyKey: kubernetes.io/hostname
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: PreferNoSchedule
defaultBackend:
nodeSelector:
node-role.kubernetes.io/edge: ''
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: PreferNoSchedule
nginx ingress controller的副本数replicaCount为1,将被调度到node1这个边缘节点上。这里并没有指定nginx ingress controller service的externalIPs,而是通过hostNetwork: true
设置nginx ingress controller使用宿主机网络。
helm repo update
helm install stable/nginx-ingress \
-n nginx-ingress \
--namespace kube-system \
-f ingress-nginx.yaml
具体信息:
[root@master /]# helm install stable/nginx-ingress -n nginx-ingress --namespace kube-system -f ingress-nginx.yaml
NAME: nginx-ingress
LAST DEPLOYED: Tue Jul 30 15:29:31 2019
NAMESPACE: kube-system
STATUS: DEPLOYED
RESOURCES:
==> v1/ConfigMap
NAME DATA AGE
nginx-ingress-controller 1 <invalid>
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
nginx-ingress-controller-657658b9b-xxq8r 0/1 ContainerCreating 0 <invalid>
nginx-ingress-default-backend-f8b68765c-fgjfs 0/1 ContainerCreating 0 <invalid>
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-ingress-controller LoadBalancer 10.108.248.196 <pending> 80:30839/TCP,443:32156/TCP <invalid>
nginx-ingress-default-backend ClusterIP 10.97.98.91 <none> 80/TCP <invalid>
==> v1beta1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-ingress-controller 0/1 1 0 <invalid>
nginx-ingress-default-backend 0/1 1 0 <invalid>
==> v1beta1/PodDisruptionBudget
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE
nginx-ingress-controller 1 N/A 0 <invalid>
nginx-ingress-default-backend 1 N/A 0 <invalid>
NOTES:
The nginx-ingress controller has been installed.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl --namespace kube-system get services -o wide -w nginx-ingress-controller'
An example Ingress that makes use of the controller:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: example
namespace: foo
spec:
rules:
- host: www.example.com
http:
paths:
- backend:
serviceName: exampleService
servicePort: 80
path: /
# This section is only required if TLS is to be enabled for the Ingress
tls:
- hosts:
- www.example.com
secretName: example-tls
If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:
apiVersion: v1
kind: Secret
metadata:
name: example-tls
namespace: foo
data:
tls.crt: <base64 encoded cert>
tls.key: <base64 encoded key>
type: kubernetes.io/tls
直接使用命令安装
helm install stable/nginx-ingress \
-n nginx-ingress \
--namespace kube-system \
--set controller.hostNetwork=true,rbac.create=true \
--set controller.replicaCount=1
输出:
[root@master /]# helm install stable/nginx-ingress \
> -n nginx-ingress \
> --namespace kube-system \
> --set controller.hostNetwork=true,rbac.create=true \
> --set controller.replicaCount=1
Error: release nginx-ingress failed: Deployment in version "v1beta1" cannot be handled as a Deployment: v1beta1.Deployment.Spec: v1beta1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.HostNetwork: ReadBool: expect t or f, but found ", error found in #10 byte of ...|Network":"true,rba|..., bigger context ...|s":{}}],"dnsPolicy":"ClusterFirst","hostNetwork":"true,rbac.create=true","serviceAccountName":"def|...
安装异常,我这里的helm安装的时候没有设置rbac,去掉重新安装即可
[root@master /]# helm install stable/nginx-ingress \
> -n nginx-ingress \
> --namespace kube-system \
> --set controller.hostNetwork=true,controller.replicaCount=1
NAME: nginx-ingress
LAST DEPLOYED: Tue Jul 30 15:19:59 2019
NAMESPACE: kube-system
STATUS: DEPLOYED
RESOURCES:
==> v1/ConfigMap
NAME DATA AGE
nginx-ingress-controller 1 <invalid>
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
nginx-ingress-controller-67db56c89f-2hkxq 0/1 ContainerCreating 0 <invalid>
nginx-ingress-default-backend-878d64884-q4fmt 0/1 ContainerCreating 0 <invalid>
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-ingress-controller LoadBalancer 10.108.107.199 <pending> 80:31412/TCP,443:31392/TCP <invalid>
nginx-ingress-default-backend ClusterIP 10.107.244.59 <none> 80/TCP <invalid>
==> v1beta1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-ingress-controller 0/1 1 0 <invalid>
nginx-ingress-default-backend 0/1 1 0 <invalid>
==> v1beta1/PodDisruptionBudget
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE
nginx-ingress-controller 1 N/A 0 <invalid>
nginx-ingress-default-backend 1 N/A 0 <invalid>
NOTES:
The nginx-ingress controller has been installed.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl --namespace inkube-systemet services -o wide -w nginx-ingress-controller'
An example Ingress that makes use of the controller:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: example
namespace: foo
spec:
rules:
- host: www.example.com
http:
paths:
- backend:
serviceName: exampleService
servicePort: 80
path: /
# This section is only required if TLS is to be enabled for the Ingress
tls:
- hosts:
- www.example.com
secretName: example-tls
If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:
apiVersion: v1
kind: Secret
metadata:
name: example-tls
namespace: foo
data:
tls.crt: <base64 encoded cert>
tls.key: <base64 encoded key>
type: kubernetes.io/tls
使用externalIP方式对外暴露服务:
helm install stable/nginx-ingress \
-n nginx-ingress \
--namespace kube-system \
--set controller.service.externalIPs[0]=18.16.202.163
查看:
[root@master /]# kubectl get po,svc -n kube-system
NAME READY STATUS RESTARTS AGE
pod/nginx-ingress-controller-7d4f8b4fbc-rv52j 1/1 Running 0 44m
pod/nginx-ingress-default-backend-59944969d4-df8cl 1/1 Running 0 44m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/nginx-ingress-controller LoadBalancer 10.103.227.228 18.16.202.163 80:30289/TCP,443:30669/TCP 44m
service/nginx-ingress-default-backend ClusterIP 10.106.189.109 <none> 80/TCP 44m
删除nginx-ingress
删除nginx-ingress
[root@master /]# helm delete nginx-ingress
release "nginx-ingress" deleted
[root@master /]# helm ls --all nginx-ingress
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
nginx-ingress 1 Tue Jul 30 14:31:01 2019 DELETED nginx-ingress-0.9.5 0.10.2 kube-system
[root@master /]# helm delete --purge nginx-ingress
release "nginx-ingress" deleted
[root@master /]# helm ls --all nginx-ingress
使用--purge
参数可以彻底删除release不留下记录,否则下一次部署的时候不能使用重名的release。
安装成功查看
查看
[root@master /]# kubectl get po,svc -n kube-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/nginx-ingress-controller-b89575c7f-2xtkk 1/1 Running 0 13m 18.16.202.163 master <none> <none>
pod/nginx-ingress-default-backend-7b8b45bd49-g4mbz 1/1 Running 0 13m 10.244.0.23 master <none> <none>
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/nginx-ingress-controller LoadBalancer 10.111.25.193 <pending> 80:31577/TCP,443:31246/TCP 13m app=nginx-ingress,component=controller,release=nginx-ingress
service/nginx-ingress-default-backend ClusterIP 10.106.126.222 <none> 80/TCP 13m app=nginx-ingress,component=default-backend,release=nginx-ingress
helm查看:
[root@master /]# helm ls --all nginx-ingress
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
nginx-ingress 1 Tue Jul 30 14:39:58 2019 DEPLOYED nginx-ingress-0.9.5 0.10.2 kube-system
访问验证:
[root@master /]# curl http://18.16.202.163
default backend - 404
http测试:
[root@master /]# curl -I http://18.16.202.163/healthz/
HTTP/1.1 200 OK
Server: openresty/1.15.8.1
Date: Tue, 20 Aug 2019 10:11:11 GMT
Content-Type: text/html
Content-Length: 0
Connection: keep-alive
https:
[root@master /]# curl -kI https://k8s.hongda.com/
HTTP/1.1 200 Connection established
HTTP/1.1 200 OK
Server: openresty/1.15.8.1
Date: Tue, 20 Aug 2019 16:22:06 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 990
Connection: keep-alive
Vary: Accept-Encoding
Accept-Ranges: bytes
Cache-Control: no-store
Last-Modified: Mon, 17 Dec 2018 09:04:43 GMT
Strict-Transport-Security: max-age=15724800; includeSubDomains
参考:
利用cert-manager让Ingress启用免费的HTTPS证书
Helm 安装Nginx Ingress的更多相关文章
- [经验交流] Kubernetes Nginx Ingress 安装与使用
Ingress 介绍 Kubernetes 上部署的微服务运行在它的私有网络中, 通过Pod实例的hostPort或Service实例的NodePort可以暴露到主机端口上,便于用户访问.但这样的方法 ...
- 国内不fq安装K8S三: 使用helm安装kubernet-dashboard
目录 3 使用helm安装kubernet-dashboard 3.1 Helm的安装 3.2 使用Helm部署Nginx Ingress 3.3 使用Helm部署dashboard 3.4 使用He ...
- Helm 安装部署Kubernetes的dashboard
Kubernetes Dashboard 是 k8s集群的一个 WEB UI管理工具,代码托管在 github 上,地址:https://github.com/kubernetes/dashboard ...
- Nginx Ingress on TKE 部署最佳实践
概述 开源的 Ingress Controller 的实现使用量最大的莫过于 Nginx Ingress 了,功能强大且性能极高.Nginx Ingress 有多种部署方式,本文将介绍 Nginx I ...
- Kubernetes用Helm安装Ingress并踩一下使用的坑
1 前言 欢迎访问南瓜慢说 www.pkslow.com获取更多精彩文章! Ingress是Kubernetes一个非常重要的Controller,它类似一个路由转发的组件,可以让外界访问Kubern ...
- 使用helm安装ingress,实现用域名的方式访问k8s内部应用
k8s集群版本 k8s集群版本是1.22 提前部署好nginx服务和创建好svc deployment方式部署的nginx服务,1个副本 创建的服务 通过服务可以代理到nginx服务 curl 10. ...
- helm 安装prometheus operator 并监控ingress
1.helm安装 curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.shchmod 7 ...
- kubernetes 1.14安装部署ingress
简单介绍: Ingress是Kubernetes API的标准资源类型之一,它其实就是一组基于DNS名称或URL路径把请求转发至指定的Service资源的规则,用来将集群外部的请求流量转发至集群内部. ...
- 使用helm安装jenkin和gitlab
一.使用服务介绍 存储: 阿里云NAS k8s网络插件: calico k8s版本: 1.15.2 二.helm安装 https://www.cnblogs.com/zhangb8042/p/1020 ...
随机推荐
- shell脚本监控httpd服务80端口状态
监控httpd服务端口状态,根据端口判断服务器是否启动,如果没有启动则脚本自动拉起服务,如果服务正在运行则退出脚本程序:如果换成别的服务端口也可以,但是脚本程序需要做调整. #!/bin/bash # ...
- jquery如何遍历table,并对table里的某一个单元格进行操作
1.如何根据每一行的某一列的值进行比较或其他操作,进而修改另一列的值或属性. $("#table_id tbody tr").each(function(){ var a = $( ...
- react 父组件调用子组件方法、子组件调用父组件方法
我们闲话不多说,直接上代码 // 父组件 import React, {Component} from 'react'; class Parents extends Component { const ...
- word 转 pfd
转自: https://www.cnblogs.com/qiwu1314/p/6101400.html demo: public class Doc2Pdf { public static boole ...
- jupyter lab matplotlib 画图
解决jupyter lab plt.plot() 不画图的问题 import matplotlib.pyplot as plt %matplotlib inline #insert this c ...
- 在Windows 10中禁用自动文件夹类型发现
点击下载注册表文件:https://files.cnblogs.com/files/Music/win10_automatic_folder_type_discovery.zip 已知Windows ...
- kubernetes支持local volume
目录 local volume 创建一个storage class 静态创建PV 使用local volume PV 动态创建PV local volume kubernetes从1.10版本开始支持 ...
- 【Java并发编程】24、Synchronized实现原理解析
一.概述 我们知道在JDK1.5之前synchronized是一个重量级锁,相对于j.u.c.Lock,它会显得那么笨重,以至于我们认为它不是那么的高效而慢慢摒弃它. 不过,随着后续Java版本更新对 ...
- windows 下安装 node 以及安装 git 指令使用
一.先百度搜索 node 找 Download | Node.js 二.下载 Node 根据你自己的操作系统下载 三.安装 node (注意:如果安装失败,使用管理员身份打开安装) 四.安装成功之后 ...
- 【数据库-MySql】开启事件 event_scheduler
Navicat Premium 事件计划已关闭.事件只能在服务器启动并开启事件计划时才能处理. Navicat for MySQL The event_scheduler is Off. Events ...