-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
K3s reapplies "master" node-role label to single node cluster on server restart. #2124
Comments
I'm adding the "raw" ccm manifest via cloud-init to install.sh #!/bin/bash
provider_id="$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)/$(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
curl -sfL https://get.k3s.io -o /k3s_install.sh
chmod +x /k3s_install.sh
/k3s_install.sh \
--disable-cloud-controller \
--disable servicelb \
--disable local-storage \
--disable traefik \
--kubelet-arg="cloud-provider=external" \
--kubelet-arg="provider-id=aws:///${provider_id}"
rm /k3s_install.sh
# wait for cluster up.
return=1
while [ ${return} != 0 ]; do
sleep 2
kubectl get nodes $(hostname -f) 2>&1 >/dev/null
return=$?
done
# re-lable if single node cluster. AWS CCM doesn't run on "master" nodes.
if [ "${NODE_ROLE}" == "single" ]; then
is_master=$(kubectl get node -o json | jq -r ".items[] | select(.metadata.name == \"$(hostname -f)\") | .metadata.labels.\"node-role.kubernetes.io/master\"")
if [ "${is_master}" == "true" ]; then
kubectl label node $(hostname -f) node-role.kubernetes.io/master- node-role.kubernetes.io/single="true"
fi
fi 00-aws-ccm.yaml apiVersion: v1
kind: ServiceAccount
metadata:
name: cloud-controller-manager
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: system:cloud-controller-manager
labels:
kubernetes.io/cluster-service: "true"
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- '*'
- apiGroups:
- ""
resources:
- nodes/status
verbs:
- patch
- apiGroups:
- ""
resources:
- services
verbs:
- list
- watch
- patch
- apiGroups:
- ""
resources:
- services/status
verbs:
- update
- patch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- update
# For leader election
- apiGroups:
- ""
resources:
- endpoints
verbs:
- create
- apiGroups:
- ""
resources:
- endpoints
resourceNames:
- "cloud-controller-manager"
verbs:
- get
- list
- watch
- update
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- apiGroups:
- ""
resources:
- configmaps
resourceNames:
- "cloud-controller-manager"
verbs:
- get
- update
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- create
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- apiGroups:
- "coordination.k8s.io"
resources:
- leases
verbs:
- get
- create
- update
- list
# For the PVL
- apiGroups:
- ""
resources:
- persistentvolumes
verbs:
- list
- watch
- patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: aws-cloud-controller-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:cloud-controller-manager
subjects:
- kind: ServiceAccount
name: cloud-controller-manager
namespace: kube-system
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: aws-cloud-controller-manager-ext
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
name: cloud-controller-manager
namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: aws-cloud-controller-manager
namespace: kube-system
labels:
k8s-app: aws-cloud-controller-manager
spec:
selector:
matchLabels:
component: aws-cloud-controller-manager
tier: control-plane
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
component: aws-cloud-controller-manager
tier: control-plane
spec:
serviceAccountName: cloud-controller-manager
hostNetwork: true
# If this is a single node we do not want this selector
# and we need to remove the node-role.kubernetes.io/master label
# Maybe set node-role.kubernetes.io/combined: "true"
# nodeSelector:
# node-role.kubernetes.io/master: "true"
tolerations:
- key: node.cloudprovider.kubernetes.io/uninitialized
value: "true"
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: aws-cloud-controller-manager
image: jgreat/aws-cloud-controller-manager:20200331-095641 |
Here's a temporary workaround just in case someone else runs into this. As part of my install, I'm adding a couple of 'ExecStartPost' commands to the k3s systemd service. This should remove the "master" label if the service is restarted.
|
Tried the methods above for rke2 cluster (3 nodes) - the |
Yes, there is not currently any way to prevent K3s from reapplying the master/control-plane roles on startup. FWIW I don't see anything in the out-of-tree cloud provider at https://github.com/kubernetes/cloud-provider-aws, nor the legacy in-tree cloud provider, that would prevent nodes with a master role from serving the ELB? Where are you seeing this restriction? |
@brandond I'm attempting to run RKE2 with aws-cloud-provider, 3 nodes. So, unless I will remove the |
Ah I see, it's not that it's just excluded from the ELB by the cloud provider, it's excluded from showing up in Service endpoints. As per kubernetes/kubernetes#90126 it looks like this should be fixable now, and fixed by default in v1.20 - have you tried turning the
|
I have tried with version
|
Have you tried turning the referenced FeatureGate off? It appears that upstream did not in fact disable it by default in 1.20 as they had proposed doing in that PR. According to the docs, 1.19 moved it to Beta but it remains true by default. |
I actually tried adding it as a kubelet arg Currently not sure if this now is a problem with the cloud controller or k8s / k3s |
I don't think that's a kubelet feature-gate, you'll probably need to pass it as a controller-manager and/or apiserver arg. If you're running an out-of-tree cloud controller you'd need to pass it to that. |
Thanks for the hint, it needs to be added to the kubelet and the controller-manager 👍 |
Closing - K3s will continue to apply the role labels; anyone that has an issue with this due to the endpoint controller not including addresses for nodes with master/control-plane role labels can use the |
Environmental Info:
Node(s) CPU architecture, OS, and Version:
Cluster Configuration:
Describe the bug:
Occasionally the k3s server instance has an internal timeout (will file a different issue for that) and systemd will restart the k3s service. When this happens k3s will re-apply the
node-role.kubernetes.io/master=true
label to the node. This "breaks" the AWS CCM since that service will not addmaster
nodes to the CCM managed AWS load balancer pools.Steps To Reproduce:
Add
single
role label and removemaster
role labelValidate that only the
single
role is enabledRestart
k3s
serviceExpected behavior:
Only
single
role label should be appliedActual behavior:
master
label has been reappliedThe text was updated successfully, but these errors were encountered: