Error on warning

Hi,
while bootstrapping a new k8s cluster I realized that kubeadm init was showing some warnings:

W1011 09:21:36.955799    3289 common.go:101] your configuration file uses a deprecated API spec: "kubeadm.k8s.io/v1beta3" (kind: "ClusterConfiguration"). Please use 'kubeadm config migrate --old-config old.yaml --new-config new.yaml', which will write the new, similar spec using a newer API version.
W1011 09:21:36.956190    3289 common.go:101] your configuration file uses a deprecated API spec: "kubeadm.k8s.io/v1beta3" (kind: "InitConfiguration"). Please use 'kubeadm config migrate --old-config old.yaml --new-config new.yaml', which will write the new, similar spec using a newer API version.

If you use some kind of automation, like ansible, the output is hidden and you will never be aware of warnings.

Is there an option to threat warning as errors, in order to surface warnings?

(Apart parsing the command output an look for ^W or warning)

Thanks

1 Like

I dont know a way to do it natively but if you want to theat warning to error you need a wrapper on top of original software like ansible or any other script or tool to convert warning to error.

- name: Initialize the cluster
  shell: kubeadm init 2>&1
  register: kubeadm_output
  failed_when: "'^W' in kubeadm_output.stdout"
  changed_when: False
3 Likes

Thanks for the reply.

I would have preferred and upstream solution but your suggestion also works.

2 Likes