medmouine/vagrant-k3s-HA-cluster

error while calling `vagrant up` command

Closed this issue · 2 comments

I got this error message while calling vagrant up

Bringing machine 'front_lb' up with 'virtualbox' provider...
Bringing machine 'kubemaster1' up with 'virtualbox' provider...
Bringing machine 'kubemaster2' up with 'virtualbox' provider...
Bringing machine 'kubemaster3' up with 'virtualbox' provider...
Bringing machine 'kubenode1' up with 'virtualbox' provider...
Bringing machine 'kubenode2' up with 'virtualbox' provider...
Bringing machine 'kubenode3' up with 'virtualbox' provider...
==> front_lb: Checking if box 'generic/alpine312' version '3.2.22' is up to date...
==> front_lb: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> front_lb: flag to force provisioning. Provisioners marked to run always will still run.
==> kubemaster1: Checking if box 'generic/alpine312' version '3.2.22' is up to date...
==> kubemaster1: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> kubemaster1: flag to force provisioning. Provisioners marked to run always will still run.
==> kubemaster1: Running action triggers after up ...
==> kubemaster1: Running trigger...
==> kubemaster1: m11 Provisioning: Init Cluster. HOST:kubemaster1, IP: 10.0.0.11, args: init 10.0.0.11 10.0.0.30 v1.21.0+k3s1
    kubemaster1: Running local script: scripts/provision.sh
    kubemaster1: + [ 12 -gt 0 ]
    kubemaster1: 
    kubemaster1: + [[ --action == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 11 -gt 0 ]
    kubemaster1: + [[ init == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 10 -gt 0 ]
    kubemaster1: + [[ --interface == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 9 -gt 0 ]
    kubemaster1: + [[ eth1 == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 8 -gt 0 ]
    kubemaster1: + [[ --ip == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 7 -gt 0 ]
    kubemaster1: + [[ 10.0.0.11 == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 6 -gt 0 ]
    kubemaster1: + [[ --vip == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 5 -gt 0 ]
    kubemaster1: + [[ 10.0.0.30 == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 4 -gt 0 ]
    kubemaster1: + [[ --version == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 3 -gt 0 ]
    kubemaster1: + [[ v1.21.0+k3s1 == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 2 -gt 0 ]
    kubemaster1: + [[ --token == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 1 -gt 0 ]
    kubemaster1: + [[ agent-token == *--* ]]
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 5: [[: not found
    kubemaster1: + shift
    kubemaster1: + [ 0 -gt 0 ]
    kubemaster1: 
    kubemaster1: /home/maletxa/Documents/GLO7008/vagrant-k3s-HA-cluster/scripts/provision.sh: 12: action: parameter not set
    kubemaster1: 
==> kubemaster1: Trigger run failed
==> kubemaster1: A script exited with an unacceptable exit code 2.
A script exited with an unacceptable exit code 2.

This is most likely a compatibility issue between standard Shellscript and the sh runner you are using.

The provision.sh script runs on your local host machine and the error is happening during the parsing of the arguments passed to the script.

Can you try some alternations of this chunk of code in provision.sh

while [ $# -gt 0 ]; do
   if [[ $1 == *"--"* ]]; then
        v="${1/--/}"
        declare $v="$2"
   fi
  shift
done

For example, try alternating different [[ ]] combinations.

You can also look up how to parse arguments for you specific OS in shell script, it should be standard for all unix distros, but I can't be sure as I only tested on macOS Catalina 10.15.7.

Please post your solution if you are able to resolve the issue.

The fix was not really obvious...I had to: 0

  • remove the entire project
  • clone it again
  • change the hosts.yaml file to get a good ip addresses
    • (note that they are 2 ip addresses to change (the first in the ip_range, the second is the ip param form the lb part. Be sure they are the sames)
    • Remembre to change the ip addresse in the docker command to!

and.....that's it! vagrant up worked

EDIT : Just to be sure, I tried this solution before (i.e - change the hosts.yamlfile to get a good ip addresses ) without removing the project before and it didn't worked...Don't know why because it recreate the project anyway.