K8S Helm 安装ingress-nginx/ingress-nginx

  • 安装ingress-nginx/ingress-nginx

    • 参考:
    • https://www.cnblogs.com/syushin/p/15271304.html
  • 添加helm仓库

    - [root@k8s-master ~]# helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
    - [root@k8s-master ~]# helm repo update    

  • 下载安装包

    • helm pull ingress-nginx/ingress-nginx
      • 解压
        • tar -zxvf ingress-nginx-4.0.1.tgz
  • 备份并修改 values.yaml 文件

    • 修改controller的镜像地址
controller:name: /enableAnnotationValidations: falseimage:## Keep false as default for now!chroot: falseregistry: docker.ioimage: willdockerhub/ingress-nginx-controller## for backwards compatibility consider setting the full image url via the repository value below## use *either* current default registry/image or repository format or installing chart by providing the values.yaml will fail## repository:tag: "v1.0.0"digest: sha256:0851b34f69f69352bf168e6ccf30e1e20714a264ab1ecd1933e4d8c0fc3215c6pullPolicy: IfNotPresent# www-data -> uid 101runAsUser: 101allowPrivilegeEscalation: true
    • 修改 hostNetwork 的值为 true:

# is merged hostNetwork: true ## Use host ports 80 and 443

    • dnsPolicy的值改为: ClusterFirstWithHostNet

# to keep resolving names inside the k8s network, use ClusterFirstWithHostNet. dnsPolicy: ClusterFirstWithHostNet

    • nodeSelector 添加标签: ingress: "true",用于部署 ingress-controller 到指定节点
 # -- Node labels for controller pod assignment## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/##nodeSelector:kubernetes.io/os: linuxingress: "true"
    • kind类型更改为:DaemonSet
 # -- Use a `DaemonSet` or `Deployment`kind: DaemonSet# -- Annotations to be added to the controller Deployment or DaemonSet
    • kube-webhook-certgen的镜像地址改为国内仓库地址
patch:enabled: trueimage:registry: registry.cn-hangzhou.aliyuncs.comimage: google_containers/kube-webhook-certgen## for backwards compatibility consider setting the full image url via the repository value below## use *either* current default registry/image or repository format or installing chart by providing the values.yaml will fail## repository:tag: "v20231011-8b53cabe0"#digest: sha256:a7943503b45d552785aa3b5e457f169a5661fb94d82b8a3373bcd9ebaf9aac80digest: sha256:488fc1dcc9269161ac781ffb5df0a9751cb64693bf195fe76e57f211db332dd9pullPolicy: IfNotPresent
  • 安装

    • 使用当前目录中的values.yaml文件
      • helm install ingress-nginx -n ingress-nginx .
    • 指定values.yaml文件,并使用debug参数,方便调试异常
      • helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx -n ingress-nginx --values values.yaml --debug
        • upgrade --install 会导致重新下载包
          • 如果不想重新下载,直接使用install
    • 安装成功,并给了一个创建ingress的例子
NOTES:
The ingress-nginx 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 ingress-nginx get services -o wide -w ingress-nginx-controller'An example Ingress that makes use of the controller:apiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: examplenamespace: foospec:ingressClassName: nginxrules:- host: www.example.comhttp:paths:- pathType: Prefixbackend:service:name: exampleServiceport:number: 80path: /# This section is only required if TLS is to be enabled for the Ingresstls:- hosts:- www.example.comsecretName: example-tlsIf TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:apiVersion: v1kind: Secretmetadata:name: example-tlsnamespace: foodata:tls.crt: <base64 encoded cert>tls.key: <base64 encoded key>type: kubernetes.io/tls
  • 处于pending状态的ingress-nginx-controller
[root@k8s-master01 ingress-nginx]# kubectl get svc -n ingress-nginx
NAME                                 TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.99.163.44    <pending>     80:31268/TCP,443:31052/TCP   4m54s
ingress-nginx-controller-admission   ClusterIP      10.100.131.12   <none>        443/TCP                      4m54s[root@k8s-master01 ingress-nginx]# kubectl --namespace ingress-nginx get services -o wide -w ingress-nginx-controller
NAME                       TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE   SELECTOR
ingress-nginx-controller   LoadBalancer   10.99.163.44   <pending>     80:31268/TCP,443:31052/TCP   94s   app.kubernetes.io/component=controller,app.kubernetes.io/instance=ingress-nginx,app.kubernetes.io/name=ingress-nginx

  • 给节点打标签ingress=true
    • 需要给节点打上刚刚设置的标签ingress=true,让 Pod 调度到指定的节点,比如调度到 master 节点
# 给master节点打上标签 ingress=ture
[root@k8s-master ingress-nginx]# kubectl label node master1 ingress=true
node/master1 labeled# k8s默认集群中,出于安全考虑,默认配置下Kubernetes不会将Pod调度到Master节点。测试环境无所谓,所以执行下面命令去除master的污点:
[root@k8s-master ingress-nginx]# kubectl taint node master1 node-role.kubernetes.io/master-

参考:

How do I set up a pod to allow scheduling on the master · Issue #1814 · k3s-io/k3s · GitHub How do I set up a pod to allow scheduling on the master

K8S 将 pod 调度到指定 nodes 上运行 - 知乎 K8S 将 pod 调度到指定 nodes 上运行

[root@master01 rocketmq]# kubectl describe nodes | grep Taints
Taints:             node-role.kubernetes.io/control-plane:NoSchedule
Taints:             <none>
Taints:             <none>
[root@master01 rocketmq]# kubectl taint nodes --all node-role.kubernetes.io/control-plane-
node/master01 untainted
taint "node-role.kubernetes.io/control-plane" not found
taint "node-role.kubernetes.io/control-plane" not found
[root@master01 rocketmq]# kubectl describe nodes | grep Taints
Taints:             <none>
Taints:             <none>
Taints:             <none>
[root@master01 rocketmq]# kubectl get nodes
NAME       STATUS   ROLES           AGE   VERSION
master01   Ready    control-plane   44d   v1.28.2
node02     Ready    <none>          44d   v1.28.2
node03     Ready    <none>          44d   v1.28.2
[root@master01 rocketmq]# kubectl describe nodes | grep Taints
Taints:             <none>
Taints:             <none>
Taints:             <none>
[root@master01 rocketmq]# kubectl get pods -A -owide |grep ingress
ingress-nginx            ingress-nginx-controller-bc96v                           1/1     Running            0                  41s     yourip     master01   <none>           <none>

k8s命令(pod相关(驱逐、强制删除)、让Master当Node用、修改nodeport端口范围、修改k8sDNS、运行nslookup容器)_kubectl drain-CSDN博客

#将 Master 也当作 Node 使用
kubectl taint node nodename node-role.kubernetes.io/master-[root@app01 home]# kubectl taint node app01 node-role.kubernetes.io/master-
node/app01 untainted
[root@app01 home]# #将 Master 恢复成 Master Only 状态
kubectl taint node nodename node-role.kubernetes.io/master="":NoSchedule[root@app01 rabbitmq]# kubectl taint node app01  node-role.kubernetes.io/master="":NoSchedule
node/app01 tainted
[root@app01 rabbitmq]# 
    • 本次直接将标签打到了node02上
      • 所以配置的域名要指向node02节点的ip地址
      • ingress-nginx-controller对应的pod会自动部署到node02节点上
  • 配置访问hosts

    • 192.168.221.132 harbor.david.org
    • 测试
      • 用浏览器访问没问,curl缺少header中的一些参数,所以报308错误
[root@k8s-master01 harbor]# curl harbor.david.org
<html>
<head><title>308 Permanent Redirect</title></head>
<body>
<center><h1>308 Permanent Redirect</h1></center>
<hr><center>nginx</center>
</body>
</html>
  • configmap权限异常处理

  • 查看ingress-nginx-controller日志
    • [root@k8s-master01 harbor]# kubectl logs -n ingress-nginx ingress-nginx-controller-4nl8l
      • E1122 05:49:57.933496 7 leaderelection.go:329] error initially creating leader election record: configmaps is forbidden: User "system:serviceaccount:ingress-nginx:ingress-nginx" cannot create resource "configmaps" in API group "" in the namespace "ingress-nginx"
        • 需要create和update权限,修改role即可
          • [root@k8s-master01 nginx]# kubectl edit clusterrole -n ingress-nginx ingress-nginx
            • 添加
              • - create
              • - update
            • 保存并退出,再查看ingress-nginx-controller日志
              • [root@k8s-master01 harbor]# kubectl logs -n ingress-nginx ingress-nginx-controller-4nl8l
          • configmaps (用于配置文件注入)
rules:
- apiGroups:- ""resources:- configmaps- endpoints- nodes- pods- secrets- namespacesverbs:- list- watch- create- update
  • 异常调试

    • 安装加上debug参数 展示详细安装过程,方便排查错误
    • client.go:779: [debug] ingress-nginx-admission-create: Jobs active: 0, jobs failed: 0, jobs succeeded: 0
    • 提示job有异常,先找到这个job
[root@k8s-master01 ingress-nginx]# kubectl get job -A
NAMESPACE       NAME                             COMPLETIONS   DURATION   AGE
ingress-nginx   ingress-nginx-admission-create   0/1           8s         8s
ingress-nginx   ingress-nginx-admission-patch    0/1           69m        69m[root@k8s-master01 ingress-nginx]# kubectl get pods -A
ingress-nginx          ingress-nginx-admission-create-r7bps    
  • 有个job对应的pod有异常

[root@k8s-master01 ingress-nginx]# kubectl describe pods -n ingress-nginx          ingress-nginx-admission-create-r7bpsNormal   BackOff    5s (x2 over 28s)   kubelet            Back-off pulling image "registry.aliyuncs.com/google_containers/kube-webhook-certgen:v1.5.1@sha256:a7943503b45d552785aa3b5e457f169a5661fb94d82b8a3373bcd9ebaf9aac80"

提示镜像有异常

Failed to pull image "registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v20231011-8b53cabe0@sha256:a7943503b45d552785aa3b5e457f169a5661fb94d82b8a3373bcd9ebaf9aac80": rpc error: code = NotFound desc = failed to pull and unpack image "registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen@sha256:a7943503b45d552785aa3b5e457f169a5661fb94d82b8a3373bcd9ebaf9aac80": failed to resolve reference "registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen@sha256:a7943503b45d552785aa3b5e457f169a5661fb94d82b8a3373bcd9ebaf9aac80": registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen@sha256:a7943503b45d552785aa3b5e457f169a5661fb94d82b8a3373bcd9ebaf9aac80: not found

修改了镜像还不管用,还需要修改sha256

使用ctr下载该镜像

[root@k8s-master01 ingress-nginx]# ctr -n=k8s.io images pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v20231011-8b53cabe0

找到该镜像

[root@k8s-master01 ingress-nginx]# ctr -n=k8s.io images list

registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v20231011-8b53cabe0 application/vnd.docker.distribution.manifest.list.v2+json sha256:488fc1dcc9269161ac781ffb5df0a9751cb64693bf195fe76e57f211db332dd9 22.1 MiB linux/amd64,linux/arm/v7,linux/arm64,linux/s390x io.cri-containerd.image=managed

把sha256字符串加到values.yaml里

digest: sha256:488fc1dcc9269161ac781ffb5df0a9751cb64693bf195fe76e57f211db332dd9

再次安装即可

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/583804.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

WebGL开发航空航天学习应用

使用 WebGL 开发航空航天学习应用可以为学生提供沉浸式的三维体验&#xff0c;帮助他们了解航空航天工程、飞行原理和宇宙空间。以下是开发航空航天学习应用的一般步骤&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c…

如何解决企业内部FTP文件传输速度过慢和安全问题

在数据化时代里&#xff0c;企业内部的文件传输永远是刚需&#xff0c;而因为 FTP协议的简单、易用、广泛支持等优点&#xff0c;让很多企业早期都普遍使用&#xff0c;随着数量量的增多&#xff0c;和对安全的要求越来越高&#xff0c;FTP也暴露出了一些列问题&#xff0c;小编…

鲫鱼养殖场污水处理设备配置报价

诸城市鑫淼环保小编带大家了解一下鲫鱼养殖场污水处理设备配置报价 一、概述 水产加工废水来自于水产加工厂的生产流程&#xff1a;原料解冻、去脏、清洗、装盘、速冻、包装以及原料冻鱼解冻、水洗、控水、消毒、清洗等工序产生生产废水&#xff0c;生产设备洗刷、车间地面产生…

AI面板识别 - 华为OD统一考试

OD统一考试 (B卷) 分值: 100分 题解: Java / Python / C++ 题目描述 AI识别到面板上有N(1 ≤ N ≤ 100)个指示灯,灯大小一样,任意两个之间无重叠。 由于AI识别误差,每次别到的指示灯位置可能有差异,以4个坐标值描述AI识别的指示灯的大小和位置(左上角x1,y1,右下角x2…

geyser互通服基岩版进不去

Java版需要在服务器安全组开通TCP端口&#xff08;如果有宝塔&#xff0c;也需要开通&#xff09; geyser下载好的安装运行也需要开通端口&#xff0c;但是它是UDP的&#xff08;但是我同时也开启了TCP&#xff0c;可能不需要&#xff1f; Java 版玩家隧道 Java 版玩家使用 T…

Solana 与 DePIN 的双向奔赴,会带来 DePIN 之夏吗?

作者&#xff1a;LBank Labs 研究员 F.F 编译&#xff1a;TinTinLand 原文&#xff1a;https://medium.com/lbanklabs/new-anchor-of-solana-depin-b674d04d6980 太长不看版 在过去的一年里&#xff0c;我们观察到 Solana 和 DePIN 两者都呈现出了显著的增长。这不仅是极客科…

论文阅读——Slide-Transformer(cvpr2023)

Slide-Transformer: Hierarchical Vision Transformer with Local Self-Attention 一、分析 1、改进transformer的几个思路&#xff1a; &#xff08;1&#xff09;将全局感受野控制在较小区域&#xff0c;如&#xff1a;PVT&#xff0c;DAT&#xff0c;使用稀疏全局注意力来…

Spring中有哪些扩展点

介绍 什么是spring扩展点 Spring 框架中的扩展点是指一组接口或机制&#xff0c;允许开发者在不修改核心框架源代码的情况下&#xff0c;定制和扩展 Spring 框架的功能、行为或配置。这些扩展点提供了一种方式&#xff0c;使开发者可以通过实现特定的接口、编写特定类型的类或…

使用 sourcetree 的《遴选》功能

假设你有一个分支&#xff0c;有两个提交 A&#xff0c;和B&#xff0c;你现在想在A提交的基础上把 B提交的功能做修改&#xff0c;你可以使用 遴选功能。 在A 提交的基础上新建一个分支&#xff0c;然后在B提交上面&#xff0c;右键&#xff0c;选择 遴选&#xff0c;那么B修改…

【开题报告】基于SSM的仓库管理系统设计与实现

1.引言 随着物流行业的蓬勃发展&#xff0c;仓库管理成为了企业物流运作中的关键环节。为了提高仓库管理的效率和准确性&#xff0c;开发一个基于SSM框架的仓库管理系统是非常必要和有意义的。 传统的仓库管理方式往往依赖于手工操作和纸质记录&#xff0c;这种方式存在着许多…

业务中台-研发

在业务中台研发阶段&#xff0c;我们主要聚焦于研发工作。首先&#xff0c;让我们了解一下我们的研发团队构成&#xff1a;UI设计师、开发工程师、测试工程师和前端工程师。 在业务中台项目中&#xff0c;我们采取了领域划分的策略&#xff0c;成立了商品、订单、库存、客户和…

软件行业也来一场“仅退款”,可行否?

“仅退款”战役&#xff0c;算是全面打响了&#xff01;某夕夕&#xff0c;用超级流量倒逼供应商提升产品品质&#xff08;这里先不能用质量一词&#xff09;&#xff0c;确实产生了奇效&#xff0c;完成了逆袭&#xff0c;现在逼得阿猫和阿狗不得不加入。但我个人认为&#xf…

工厂传送带应用西门子Profinet连接EtheCAT伺服驱动器

在工业现场&#xff0c;我们采用了1500系列的PLC&#xff0c;以及带有EtherCAT通讯协议的伺服驱动器。由于1500系列的PLC采用的是PROFINET实时以太网通讯协议&#xff0c;为了实现与EtherCAT设备的连接&#xff0c;我们必须进行通讯协议的转换。为此&#xff0c;开疆智能Profin…

计网_05IP地址

一、IP地址  &#xff11;、IP地址基本概念 用于标识网络中的某一台主机或某一个网络接口&#xff0c;主机的唯一标识&#xff0c;保证主机间的正常通信&#xff08;主机之间要想通信就必须配置相应的IP地址&#xff09; 一种网络编码&#xff0c;用来确定网络中的一个节点…

汽车发动机缸体缸盖自动化光学测量系统尺寸测量偏差检测-CASAIM品质检测自动化设备

汽车行驶在不同的环境中&#xff0c;汽车的安全性是必须考虑的&#xff0c;汽车发动机盖体缸盖的加工质量问题是汽车安全可靠性的一个关注点。目前客户检测方案是通过三坐标检测工件进行检测&#xff0c;只能对于位置点进行相关测量&#xff0c;需要规划测量路径&#xff0c;费…

Android Studio修改创建新布局时默认根布局

将Android Studio默认布局ConstraintLayout切换成LinearLayout 打开设置&#xff0c; Editor> File and Code Templates > Other > layoutResourceFile.xml 备注&#xff1a;创建时提示根布局仍然为ConstraintLayout&#xff0c;不用管这个&#xff0c;实际创建的…

炎症状态重塑了急性髓系白血病的免疫微环境并改善了风险分层

今天给同学们分享一篇实验文章“An inflammatory state remodels the immune microenvironment and improves risk stratification in acute myeloid leukemia”&#xff0c;这篇文章发表在Nat Cancer期刊上&#xff0c;影响因子为22.7。 结果解读&#xff1a; 成人和儿童AML的…

HDMI2.1输入转4Port MIPI/LVDS输出,嵌入式SPI闪存固件存储,VR和AR应用首选国产芯片方案-LT6911GXC

描述 LT6911GXC是一款高性能的HDMI2.1到MIPI或LVDS芯片&#xff0c;用于VR/显示应用。 HDCP RX作为HDCP中继器的上游&#xff0c;可配合其他芯片的HDCPTX实现中继器功能。 对于HDMI2.1输入&#xff0c;LT6911GXC可以配置为3/4通道。自适应均衡使其适合于长电缆应用&#xff0c;…

如何做好机电设备全生命周期管理?

机电设备是现代工业运作中不可或缺的重要资产&#xff0c;对生产运营具有关键影响。为了确保机电设备的长期运行和高效性能&#xff0c;机电设备全生命周期管理是必不可少的。下面将介绍一些关键步骤和策略&#xff0c;帮助企业效地进行机电设备全生命周期管理。 1. 选型和规划…