Skip to content

Instantly share code, notes, and snippets.

@leoh0
Last active August 7, 2020 00:04
Show Gist options
  • Save leoh0/add17f7439959fa1eb0d17e8f79c7fd9 to your computer and use it in GitHub Desktop.
Save leoh0/add17f7439959fa1eb0d17e8f79c7fd9 to your computer and use it in GitHub Desktop.
Example of adding another port to master server, this script is for IPTABLE backend only. If you create this to IPVS backend cluster then you will break all of the cluster.
############# CAUTION!!! #############
# DON'T USE THIS YAML TO IPVS CLUSTER
# IT WILL BREAK ALL OF THE CLUSTER
############# CAUTION!!! #############
apiVersion: v1
kind: Service
metadata:
name: pf
spec:
externalIPs:
- ${MASTER1_IP}
- ${MASTER2_IP}
- ${MASTER3_IP}
ports:
- name: http
port: 6444
protocol: TCP
targetPort: 6443
selector:
component: kube-apiserver
tier: control-plane

만약 ipvs에서 이걸 적용해서 문제시 해결 방법

아마 이상태면 kubectl command가 동작 안할 수도 있다.

왜냐하면 사실 etcd가 pod으로 떠 있는 경우 저 ip들 영향으로 peer들이 싱크를 맺지 못하고 다 로컬을 바라보게 되기 때문임.

  1. 각 마스터의 kubelet을 내림 (kube-proxy가 살아나지 못하도록)

    systemctl stop kubelet
    
  2. 각 마스터의 kube-proxy를 제거 (ipvs entry 추가하지 못하도록)

    docker stop $(docker ps | grep kube-proxy | head -n1 | awk '{print $1}')
    
  3. 각 마스터의 ipvs 엔트리를 제거

    ip a d ${MASTER1_IP} dev kube-ipvs0
    ip a d ${MASTER2_IP} dev kube-ipvs0
    ip a d ${MASTER3_IP} dev kube-ipvs0
    
  4. 이후 다시 kubelet 을 시작

    systemctl start kubelet
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment