kubekey icon indicating copy to clipboard operation
kubekey copied to clipboard

LooseVersion' object has no attribute 'version'

Open gaugys opened this issue 3 years ago • 4 comments

What is version of KubeKey has the issue?

version.BuildInfo{Version:"latest+unreleased", GitCommit:"c4c5167ad47067da17d881bbab955518920d59f8", GitTreeState:"dirty", GoVersion:"go1.16.10"}

What is your os environment?

Ubuntu 20.04.3 LTS

KubeKey config file

apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: k8s-master-01, address: 192.168.0.11, internalAddress: 192.168.0.11, user: ubuntu, password: pass1, arch: arm64}
  - {name: k8s-slave-01, address: 192.168.0.21, internalAddress: 192.168.0.21, user: ubuntu, password: pass1, arch: arm64}
  - {name: k8s-slave-02, address: 192.168.0.22, internalAddress: 192.168.0.22, user: ubuntu, password: pass1, arch: arm64}
  - {name: k8s-slave-03, address: 192.168.0.23, internalAddress: 192.168.0.23, user: ubuntu, password: pass1, arch: arm64}
  roleGroups:
    etcd:
    - k8s-master-01
    master:
    - k8s-master-01
    worker:
    - k8s-slave-01
    - k8s-slave-02
    - k8s-slave-03
  controlPlaneEndpoint:
    ##Internal loadbalancer for apiservers
    #internalLoadbalancer: haproxy

    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: v1.21.4-k3s
    clusterName: cluster.local
  network:
    plugin: flannel
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
  registry:
    registryMirrors: []
    insecureRegistries: []
  addons: []



---
apiVersion: installer.kubesphere.io/v1alpha1
kind: ClusterConfiguration
metadata:
  name: ks-installer
  namespace: kubesphere-system
  labels:
    version: v3.2.0
spec:
  persistence:
    storageClass: ""
  authentication:
    jwtSecret: ""
  local_registry: ""
  # dev_tag: ""
  etcd:
    monitoring: false
    endpointIps: localhost
    port: 2379
    tlsEnable: true
  common:
    core:
      console:
        enableMultiLogin: true
        port: 30880
        type: NodePort
    # apiserver:
    #  resources: {}
    # controllerManager:
    #  resources: {}
    redis:
      enabled: true
      volumeSize: 2Gi
    openldap:
      enabled: true
      volumeSize: 2Gi
    minio:
      volumeSize: 20Gi
    monitoring:
      # type: external
      endpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090
      GPUMonitoring:
        enabled: false
    gpu:
      kinds:
      - resourceName: "nvidia.com/gpu"
        resourceType: "GPU"
        default: false
    es:
      # master:
      #   volumeSize: 4Gi
      #   replicas: 1
      #   resources: {}
      # data:
      #   volumeSize: 20Gi
      #   replicas: 1
      #   resources: {}
      logMaxAge: 7
      elkPrefix: logstash
      basicAuth:
        enabled: false
        username: ""
        password: ""
      externalElasticsearchUrl: ""
      externalElasticsearchPort: ""
  alerting:
    enabled: true
    # thanosruler:
    #   replicas: 1
    #   resources: {}
  auditing:
    enabled: true
    # operator:
    #   resources: {}
    # webhook:
    #   resources: {}
  devops:
    enabled: true
    jenkinsMemoryLim: 2Gi
    jenkinsMemoryReq: 1500Mi
    jenkinsVolumeSize: 8Gi
    jenkinsJavaOpts_Xms: 512m
    jenkinsJavaOpts_Xmx: 512m
    jenkinsJavaOpts_MaxRAM: 2g
  events:
    enabled: false
    # operator:
    #   resources: {}
    # exporter:
    #   resources: {}
    # ruler:
    #   enabled: true
    #   replicas: 2
    #   resources: {}
  logging:
    enabled: false
    containerruntime: containerd
    logsidecar:
      enabled: true
      replicas: 2
      # resources: {}
  metrics_server:
    enabled: true
  monitoring:
    storageClass: ""
    # kube_rbac_proxy:
    #   resources: {}
    # kube_state_metrics:
    #   resources: {}
    # prometheus:
    #   replicas: 1
    #   volumeSize: 20Gi
    #   resources: {}
    #   operator:
    #     resources: {}
    #   adapter:
    #     resources: {}
    # node_exporter:
    #   resources: {}
    # alertmanager:
    #   replicas: 1
    #   resources: {}
    # notification_manager:
    #   resources: {}
    #   operator:
    #     resources: {}
    #   proxy:
    #     resources: {}
    gpu:
      nvidia_dcgm_exporter:
        enabled: false
        # resources: {}
  multicluster:
    clusterRole: none
  network:
    networkpolicy:
      enabled: false
    ippool:
      type: none
    topology:
      type: none
  openpitrix:
    store:
      enabled: false
  servicemesh:
    enabled: false
  kubeedge:
    enabled: false
    cloudCore:
      nodeSelector: {"node-role.kubernetes.io/worker": ""}
      tolerations: []
      cloudhubPort: "10000"
      cloudhubQuicPort: "10001"
      cloudhubHttpsPort: "10002"
      cloudstreamPort: "10003"
      tunnelPort: "10004"
      cloudHub:
        advertiseAddress:
          - ""
        nodeLimit: "100"
      service:
        cloudhubNodePort: "30000"
        cloudhubQuicNodePort: "30001"
        cloudhubHttpsNodePort: "30002"
        cloudstreamNodePort: "30003"
        tunnelNodePort: "30004"
    edgeWatcher:
      nodeSelector: {"node-role.kubernetes.io/worker": ""}
      tolerations: []
      edgeWatcherAgent:
        nodeSelector: {"node-role.kubernetes.io/worker": ""}
        tolerations: []

A clear and concise description of what happend.

Hello,

I'm trying to build from scratch Kubesphere on K3s based Raspberry pi ARM64 . For this reason I already made some small adjusments to downlaod right K3s bin file and also I have replatformed ks-installer to support arm64. Everything went smoothly untill this error

TASK [preinstall : KubeSphere | Stopping if Kubernetes version is nonsupport] ***
fatal: [localhost]: FAILED! => {"msg": "The conditional check 'kubernetes_version.stdout is version('v1.15.0', '>=')' failed. The error was: Version comparison: 'LooseVersion' object has no attribute 'version'"}

Relevant log output

kubectl logs ks-installer-594dcc7d58-fh68r -n kubesphere-system
2021-11-11T18:35:22Z INFO     : shell-operator latest
2021-11-11T18:35:22Z INFO     : HTTP SERVER Listening on 0.0.0.0:9115
2021-11-11T18:35:22Z INFO     : Use temporary dir: /tmp/shell-operator
2021-11-11T18:35:22Z INFO     : Initialize hooks manager ...
2021-11-11T18:35:22Z INFO     : Search and load hooks ...
2021-11-11T18:35:22Z INFO     : Load hook config from '/hooks/kubesphere/installRunner.py'
2021-11-11T18:35:24Z INFO     : Load hook config from '/hooks/kubesphere/schedule.sh'
2021-11-11T18:35:24Z INFO     : Initializing schedule manager ...
2021-11-11T18:35:24Z INFO     : KUBE Init Kubernetes client
2021-11-11T18:35:24Z INFO     : KUBE-INIT Kubernetes client is configured successfully
2021-11-11T18:35:24Z INFO     : MAIN: run main loop
2021-11-11T18:35:24Z INFO     : MAIN: add onStartup tasks
2021-11-11T18:35:24Z INFO     : QUEUE add all HookRun@OnStartup
2021-11-11T18:35:24Z INFO     : Running schedule manager ...
2021-11-11T18:35:24Z INFO     : MSTOR Create new metric shell_operator_live_ticks
2021-11-11T18:35:24Z INFO     : MSTOR Create new metric shell_operator_tasks_queue_length
2021-11-11T18:35:24Z INFO     : GVR for kind 'ClusterConfiguration' is installer.kubesphere.io/v1alpha1, Resource=clusterconfigurations
2021-11-11T18:35:24Z INFO     : EVENT Kube event '02fd19eb-e803-4027-a08a-32e8a12582a4'
2021-11-11T18:35:24Z INFO     : QUEUE add TASK_HOOK_RUN@KUBE_EVENTS kubesphere/installRunner.py
2021-11-11T18:35:27Z INFO     : TASK_RUN HookRun@KUBE_EVENTS kubesphere/installRunner.py
2021-11-11T18:35:27Z INFO     : Running hook 'kubesphere/installRunner.py' binding 'KUBE_EVENTS' ...
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'

PLAY [localhost] ***************************************************************

TASK [download : Generating images list] ***************************************
skipping: [localhost]

TASK [download : Synchronizing images] *****************************************

TASK [kubesphere-defaults : KubeSphere | Setting images' namespace override] ***
skipping: [localhost]

TASK [kubesphere-defaults : KubeSphere | Configuring defaults] *****************
ok: [localhost] => {
    "msg": "Check roles/kubesphere-defaults/defaults/main.yml"
}

TASK [preinstall : KubeSphere | Checking Kubernetes version] *******************
changed: [localhost]

TASK [preinstall : KubeSphere | Initing Kubernetes version] ********************
ok: [localhost]

TASK [preinstall : KubeSphere | Stopping if Kubernetes version is nonsupport] ***
fatal: [localhost]: FAILED! => {"msg": "The conditional check 'kubernetes_version.stdout is version('v1.15.0', '>=')' failed. The error was: Version comparison: 'LooseVersion' object has no attribute 'version'"}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=1    skipped=3    rescued=0    ignored=0

Additional information

No response

gaugys avatar Nov 11 '21 18:11 gaugys

@pixiake Please take a look on this issue.

24sama avatar Nov 12 '21 02:11 24sama

https://github.com/kubesphere/ks-installer/blob/453c47bdba3f9d91c3588aefd86ec6fe4fba874c/roles/preinstall/tasks/precheck.yaml#L11

It seems a version check error in ks-installer. You can check the cluster version using the following command:

kubectl version -o json | jq -r '.serverVersion.gitVersion'

or, You can also try to restart ks-installer:

kubectl rollout restart deploy -n kubesphere-system ks-installer

pixiake avatar Nov 12 '21 05:11 pixiake

hey,

I have a feeling that KS Installer is not able to handle +k3s1 suffix: they output is here:

{
  "clientVersion": {
    "major": "1",
    "minor": "21",
    "gitVersion": "v1.21.4+k3s1",
    "gitCommit": "3e250fdbab72d88f7e6aae57446023a0567ffc97",
    "gitTreeState": "clean",
    "buildDate": "2021-08-19T19:10:03Z",
    "goVersion": "go1.16.6",
    "compiler": "gc",
    "platform": "linux/arm64"
  },
  "serverVersion": {
    "major": "1",
    "minor": "21",
    "gitVersion": "v1.21.4+k3s1",
    "gitCommit": "3e250fdbab72d88f7e6aae57446023a0567ffc97",
    "gitTreeState": "clean",
    "buildDate": "2021-08-19T19:10:03Z",
    "goVersion": "go1.16.6",
    "compiler": "gc",
    "platform": "linux/arm64"
  }
}

the restart didn't help. and still the same error:

2021-11-12T07:28:03Z INFO     : shell-operator latest
2021-11-12T07:28:03Z INFO     : HTTP SERVER Listening on 0.0.0.0:9115
2021-11-12T07:28:03Z INFO     : Use temporary dir: /tmp/shell-operator
2021-11-12T07:28:03Z INFO     : Initialize hooks manager ...
2021-11-12T07:28:03Z INFO     : Search and load hooks ...
2021-11-12T07:28:03Z INFO     : Load hook config from '/hooks/kubesphere/installRunner.py'
2021-11-12T07:28:05Z INFO     : Load hook config from '/hooks/kubesphere/schedule.sh'
2021-11-12T07:28:05Z INFO     : Initializing schedule manager ...
2021-11-12T07:28:05Z INFO     : KUBE Init Kubernetes client
2021-11-12T07:28:05Z INFO     : KUBE-INIT Kubernetes client is configured successfully
2021-11-12T07:28:05Z INFO     : MAIN: run main loop
2021-11-12T07:28:05Z INFO     : MAIN: add onStartup tasks
2021-11-12T07:28:05Z INFO     : Running schedule manager ...
2021-11-12T07:28:05Z INFO     : QUEUE add all HookRun@OnStartup
2021-11-12T07:28:05Z INFO     : MSTOR Create new metric shell_operator_tasks_queue_length
2021-11-12T07:28:05Z INFO     : MSTOR Create new metric shell_operator_live_ticks
2021-11-12T07:28:06Z INFO     : GVR for kind 'ClusterConfiguration' is installer.kubesphere.io/v1alpha1, Resource=clusterconfigurations
2021-11-12T07:28:06Z INFO     : EVENT Kube event '37db4f61-000b-4dc3-9bdc-98fd1836c790'
2021-11-12T07:28:06Z INFO     : QUEUE add TASK_HOOK_RUN@KUBE_EVENTS kubesphere/installRunner.py
2021-11-12T07:28:08Z INFO     : TASK_RUN HookRun@KUBE_EVENTS kubesphere/installRunner.py
2021-11-12T07:28:08Z INFO     : Running hook 'kubesphere/installRunner.py' binding 'KUBE_EVENTS' ...
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'

PLAY [localhost] ***************************************************************

TASK [download : Generating images list] ***************************************
skipping: [localhost]

TASK [download : Synchronizing images] *****************************************

TASK [kubesphere-defaults : KubeSphere | Setting images' namespace override] ***
skipping: [localhost]

TASK [kubesphere-defaults : KubeSphere | Configuring defaults] *****************
ok: [localhost] => {
    "msg": "Check roles/kubesphere-defaults/defaults/main.yml"
}

TASK [preinstall : KubeSphere | Checking Kubernetes version] *******************
changed: [localhost]

TASK [preinstall : KubeSphere | Initing Kubernetes version] ********************
ok: [localhost]

TASK [preinstall : KubeSphere | Stopping if Kubernetes version is nonsupport] ***
fatal: [localhost]: FAILED! => {"msg": "The conditional check 'kubernetes_version.stdout is version('v1.15.0', '>=')' failed. The error was: Version comparison: 'LooseVersion' object has no attribute 'version'"}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=1    skipped=3    rescued=0    ignored=0

gaugys avatar Nov 12 '21 07:11 gaugys

I have submitted an issue to ks-installer.

You can try to delete the task of version checking, and then rebuild the image according to ks-installer's Dockerfile.

pixiake avatar Nov 12 '21 08:11 pixiake