gpt4 book ai didi

kubernetes - NodePort与kube-apiserver hostPort冲突

转载 作者:行者123 更新时间:2023-12-02 12:10:03 27 4
gpt4 key购买 nike

我有一个健康的k8s集群。 kube-apiserver使用端口 8443
然后我做下面的事情。我也创建/编辑服务,并分配一个固定的nodePort 8443

apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
nodePort: 8443
群集无法访问。如果我运行命令 kubectl get pods。它返回 Unable to connect to the server: EOF原因我需要运行kubectl命令来将nodePort改回来。但是我不能使用kubectl。它成为死循环。我有两个问题。
  • 我该怎么做才能恢复我的k8s集群?
  • 为什么kube-apiserver或其他组件不会阻止我将nodePort更改为 8443 ?指示端口 8443 已被使用。
  • 最佳答案

    kube-apiserver pod is a static pod brought up by kubelet using /etc/kubernetes/manifests/kube-apiserver.yaml file on master nodes


    so you can edit /etc/kubernetes/manifests/kube-apiserver.yaml ,where 8443 port is referenced and change it to a unused port. so that kube-apiserver will be available on that port. ideally kubelet tries to restart a static pod when its manifest file is changed .


    you need to edit ~/.kube/config , where 'server' address needs to be changed to new port.


    delete the problematic nodeport service .


    revert your changes in /etc/kubernetes/manifests/kube-apiserver.yaml & .kube/config file to go back to original port (8443)

    关于kubernetes - NodePort与kube-apiserver hostPort冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63880376/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com