kubean-io / kubean

:seedling: Product ready cluster lifecycle management toolchains based on kubespray and other cluster LCM engine.
https://kubean-io.github.io/kubean/
Apache License 2.0
440 stars 31 forks source link

The task includes an option with an undefined variable. The error was: #1265

Open 13567436138 opened 1 month ago

13567436138 commented 1 month ago

Describe the version version about:

  1. kubean 0.15.3
  2. kubespray
  3. kubenetes 1.29.5
  4. what CNI and itsversion
    fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: {{ hostvars[groups['kube_control_plane'][0]].ansible_host }}: 'dict object' has no attribute 'kube_control_plane'. 'dict object' has no attribute 'kube_control_plane'. {{ hostvars[groups['kube_control_plane'][0]].ansible_host }}: 'dict object' has no attribute 'kube_control_plane'. 'dict object' has no attribute 'kube_control_plane'\n\nThe error appears to be in '/kubespray/kubeconfig.yml': line 52, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: Update kubeconfig server\n      ^ here\n"}

Describe the bug A clear and concise description of what the bug is.

root@k8s-master01:~/kubean/examples/install/2.mirror# cat Cluster.yml 
# Copyright 2023 Authors of kubean-io
# SPDX-License-Identifier: Apache-2.0

apiVersion: kubean.io/v1alpha1
kind: Cluster
metadata:
  name: cluster1-online
  labels:
    clusterName: cluster1-online
spec:
  hostsConfRef:
    namespace: kubean-system
    name: online-hosts-conf
  varsConfRef:
    namespace: kubean-system
    name: online-vars-conf
root@k8s-master01:~/kubean/examples/install/2.mirror# cat ClusterOperation.yml 

cat > ClusterOperation.yml <<EOF
# Copyright 2023 Authors of kubean-io
# SPDX-License-Identifier: Apache-2.0

apiVersion: kubean.io/v1alpha1
kind: ClusterOperation
metadata:
  name: cluster1-online-install-ops
spec:
  cluster: cluster1-online
  image: ghcr.m.daocloud.io/kubean-io/spray-job:v0.15.3 # Please replace <TAG> with the specified version, such as v0.4.9
  actionType: playbook
  action: cluster.yml
  preHook:
    - actionType: playbook
      action: ping.yml
    - actionType: playbook
      action: disable-firewalld.yml
  postHook:
    - actionType: playbook
      action: kubeconfig.yml
    - actionType: playbook
      action: cluster-info.yml
EOF
root@k8s-master01:~/kubean/examples/install/2.mirror# cat HostsConfCM.yml 

cat > HostsConfCM.yml <<EOF
# Copyright 2023 Authors of kubean-io
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: ConfigMap
metadata:
  name: online-hosts-conf
  namespace: kubean-system
data:
  hosts.yml: |
    all:
      hosts:
        node1:
          ip: 192.168.229.180
          access_ip: 192.168.229.180
          ansible_host: 192.168.229.180
          ansible_connection: ssh
          ansible_user: root
          ansible_password: mark
        node2:
          ip: 192.168.229.181
          access_ip: 192.168.229.181
          ansible_host: 192.168.229.181
          ansible_connection: ssh
          ansible_user: root
          ansible_password: mark
        node3:
          ip: 192.168.229.182
          access_ip: 192.168.229.182
          ansible_host: 192.168.229.182
          ansible_connection: ssh
          ansible_user: root
          ansible_password: mark
        node4:
          ip: 192.168.229.183
          access_ip: 192.168.229.183
          ansible_host: 192.168.229.183
          ansible_connection: ssh
          ansible_user: root
          ansible_password: mark
      children:
        kube_control_plane:
          hosts:
            node1:
            node2:
        kube_node:
          hosts:
            node1:
            node2:
            node3:
            node4:
        etcd:
          hosts:
            node1:
            node2:
            node3
        k8s_cluster:
          children:
            kube_control_plane:
            kube_node:
        calico_rr:
          hosts: {}
EOF
root@k8s-master01:~/kubean/examples/install/2.mirror# cat VarsConfCM.yml 
# Copyright 2023 Authors of kubean-io
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: ConfigMap
metadata:
  name: online-vars-conf
  namespace: kubean-system
data:
  group_vars.yml: |
    container_manager: containerd
    k8s_image_pull_policy: IfNotPresent
    kube_network_plugin: calico
    kube_network_plugin_multus: false
    kube_proxy_mode: iptables
    enable_nodelocaldns: false
    etcd_deployment_type: kubeadm
    override_system_hostname: false
    ntp_enabled: true

    download_run_once: true
    download_container: false
    download_force_cache: true
    download_localhost: true

    additional_sysctl:
    - { name: kernel.pid_max, value: 4194304 }

    calico_cni_name: calico
    calico_felix_premetheusmetricsenabled: true
    calico_feature_detect_override: "ChecksumOffloadBroken=true" # FIX https://github.com/kubernetes-sigs/kubespray/pull/9261

    ##https://github.com/kubernetes-sigs/kubespray/blob/master/docs/mirror.md
    gcr_image_repo: "gcr.m.daocloud.io"
    kube_image_repo: "k8s.m.daocloud.io"
    docker_image_repo: "docker.m.daocloud.io"
    quay_image_repo: "quay.m.daocloud.io"
    github_image_repo: "ghcr.m.daocloud.io"
    files_repo: "https://files.m.daocloud.io"

    kubeadm_download_url: "{{ files_repo }}/dl.k8s.io/release/{{ kubeadm_version }}/bin/linux/{{ image_arch }}/kubeadm"
    kubectl_download_url: "{{ files_repo }}/dl.k8s.io/release/{{ kube_version }}/bin/linux/{{ image_arch }}/kubectl"
    kubelet_download_url: "{{ files_repo }}/dl.k8s.io/release/{{ kube_version }}/bin/linux/{{ image_arch }}/kubelet"
    cni_download_url: "{{ files_repo }}/github.com/containernetworking/plugins/releases/download/{{ cni_version }}/cni-plugins-linux-{{ image_arch }}-{{ cni_version }}.tgz"
    crictl_download_url: "{{ files_repo }}/github.com/kubernetes-sigs/cri-tools/releases/download/{{ crictl_version }}/crictl-{{ crictl_version }}-{{ ansible_system | lower }}-{{ image_arch }}.tar.gz"
    etcd_download_url: "{{ files_repo }}/github.com/etcd-io/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-{{ image_arch }}.tar.gz"
    calicoctl_download_url: "{{ files_repo }}/github.com/projectcalico/calico/releases/download/{{ calico_ctl_version }}/calicoctl-linux-{{ image_arch }}"
    calicoctl_alternate_download_url: "{{ files_repo }}/github.com/projectcalico/calicoctl/releases/download/{{ calico_ctl_version }}/calicoctl-linux-{{ image_arch }}"
    calico_crds_download_url: "{{ files_repo }}/github.com/projectcalico/calico/archive/{{ calico_version }}.tar.gz"
    helm_download_url: "{{ files_repo }}/get.helm.sh/helm-{{ helm_version }}-linux-{{ image_arch }}.tar.gz"
    crun_download_url: "{{ files_repo }}/github.com/containers/crun/releases/download/{{ crun_version }}/crun-{{ crun_version }}-linux-{{ image_arch }}"
    kata_containers_download_url: "{{ files_repo }}/github.com/kata-containers/kata-containers/releases/download/{{ kata_containers_version }}/kata-static-{{ kata_containers_version }}-{{ ansible_architecture }}.tar.xz"
    runc_download_url: "{{ files_repo }}/github.com/opencontainers/runc/releases/download/{{ runc_version }}/runc.{{ image_arch }}"
    containerd_download_url: "{{ files_repo }}/github.com/containerd/containerd/releases/download/v{{ containerd_version }}/containerd-{{ containerd_version }}-linux-{{ image_arch }}.tar.gz"
    nerdctl_download_url: "{{ files_repo }}/github.com/containerd/nerdctl/releases/download/v{{ nerdctl_version }}/nerdctl-{{ nerdctl_version }}-{{ ansible_system | lower }}-{{ image_arch }}.tar.gz"
    cri_dockerd_download_url: "{{ files_repo }}/github.com/Mirantis/cri-dockerd/releases/download/v{{ cri_dockerd_version }}/cri-dockerd-{{ cri_dockerd_version }}.{{ image_arch }}.tgz"

How To Reproduce Steps to reproduce the issue:

Expected behavior A clear and concise description of what you expected to happen.

Screenshots and log If applicable, add screenshots and log to help explain your problem.

Additional context Add any other context about the problem here.

13567436138 commented 1 month ago

[WARNING]: Failed to parse /conf/hosts.yml with auto plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: Expecting value: line 1 column 1 (char 0) Syntax Error while loading YAML. could not find expected ':' The error appears to be in '/conf/hosts.yml': line 47, column 5, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: node3 k8s_cluster: ^ here [WARNING]: Failed to parse /conf/hosts.yml with yaml plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: Expecting value: line 1 column 1 (char 0) Syntax Error while loading YAML. could not find expected ':' The error appears to be in '/conf/hosts.yml': line 47, column 5, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: node3 k8s_cluster: ^ here

ErikJiang commented 2 weeks ago

A colon( : ) is missing.

root@k8s-master01:~/kubean/examples/install/2.mirror# cat HostsConfCM.yml 

cat > HostsConfCM.yml <<EOF
# Copyright 2023 Authors of kubean-io
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: ConfigMap
metadata:
  name: online-hosts-conf
  namespace: kubean-system
data:
  hosts.yml: |
    all:
      hosts:
        node1:
          ip: 192.168.229.180
          access_ip: 192.168.229.180
          ansible_host: 192.168.229.180
          ansible_connection: ssh
          ansible_user: root
          ansible_password: mark
        node2:
          ip: 192.168.229.181
          access_ip: 192.168.229.181
          ansible_host: 192.168.229.181
          ansible_connection: ssh
          ansible_user: root
          ansible_password: mark
        node3:
          ip: 192.168.229.182
          access_ip: 192.168.229.182
          ansible_host: 192.168.229.182
          ansible_connection: ssh
          ansible_user: root
          ansible_password: mark
        node4:
          ip: 192.168.229.183
          access_ip: 192.168.229.183
          ansible_host: 192.168.229.183
          ansible_connection: ssh
          ansible_user: root
          ansible_password: mark
      children:
        kube_control_plane:
          hosts:
            node1:
            node2:
        kube_node:
          hosts:
            node1:
            node2:
            node3:
            node4:
        etcd:
          hosts:
            node1:
            node2:
            node3     <------ here
        k8s_cluster:
          children:
            kube_control_plane:
            kube_node:
        calico_rr:
          hosts: {}
EOF