sassoftware / viya4-iac-k8s

This project contains Terraform scripts to provision cloud infrastructure resources, when using vSphere, and Ansible to apply the needed elements of a Kubernetes cluster that are required to deploy SAS Viya platform product offerings.
Apache License 2.0
23 stars 15 forks source link

kube-vip configMap failed to be applied (task: kubernetes/loadbalancer/kube_vip) #88

Closed leonidasas closed 6 months ago

leonidasas commented 9 months ago

When creating the cluster on bare metal with Ansible, it fails while trying to apply the kube-vip ConfigMap.

The template here does not specify the properties range-development: as this behavior was changed in this commit

# Reference Link: https://kube-vip.io/docs/usage/cloud-provider/#the-kube-vip-cloud-provider-configmap
apiVersion: v1
kind: ConfigMap
metadata:
  name: kubevip
  namespace: kube-system
data:
{% for address in kubernetes_loadbalancer_addresses %}
  {{ address }}
{% endfor %}

This is the error:

TASK [kubernetes/loadbalancer/kube_vip : Apply kube-vip Cloud Provider configMap] *** Wednesday 04 October 2023 09:49:27 +0000 (0:00:00.553) 0:01:58.174 * fatal: [control]: FAILED! => {"changed": true, "cmd": "kubectl apply -f /tmp/kube-vip-cm.yaml\n", "delta": "0:00:00.282581", "end": "2023-10-04 09:49:27.960276", "msg": "non-zero return code", "rc": 1, "start": "2023-10-04 09:49:27.677695", "stderr": "Error from server (BadRequest): error when creating \"/tmp/kube-vip-cm.yaml\": ConfigMap in version \"v1\" cannot be handled as a ConfigMap: json: cannot unmarshal string into Go struct field ConfigMap.data of type map[string]string", "stderr_lines": ["Error from server (BadRequest): error when creating \"/tmp/kube-vip-cm.yaml\": ConfigMap in version \"v1\" cannot be handled as a ConfigMap: json: cannot unmarshal string into Go struct field ConfigMap.data of type map[string]string"], "stdout": "", "stdout_lines": []}

If /tmp/kube-vip-cm.yaml is updated with range-development: the ConfigMap is created correctly

jarpat commented 7 months ago

Hey @leonidasas, Are you still running into this issue? I was not able to recreate this problem using viya4-iac-k8s:3.6.0. I believe the issue may be how you defined the kubernetes_loadbalancer_addresses in your ansible-vars.yaml, could you share your what you set for that?

For context this is what I tested with and did not run into the error you saw.

ansible-vars.yaml snippet

kubernetes_loadbalancer : "kube_vip" # Load Balancer accepted values [kube_vip,metallb]
kubernetes_loadbalancer_addresses :
  - "range-global: 10.12.202.126-10.12.202.127"
  - "range-development: 10.12.127.254-10.12.127.255"

checking config map

$ kubectl get cm kubevip -n kube-system -o yaml
apiVersion: v1
data:
  range-development: 10.12.127.254-10.12.127.255
  range-global: 10.12.202.126-10.12.202.127
kind: ConfigMap
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"range-development":"10.12.127.254-10.12.127.255","range-global":"10.12.202.126-10.12.202.127"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"kubevip","namespace":"kube-system"}}
  creationTimestamp: "2023-12-06T20:49:51Z"
  name: kubevip
  namespace: kube-system
  resourceVersion: "1626"
  uid: 6c928d28-4791-4236-a0f6-b0cb3ffee0dc
jarpat commented 6 months ago

Marking as stale/inactive. If there are further questions please open a new GitHub issue.