voxpupuli / puppet-k8s

Home for the K8s Puppet module
Apache License 2.0
9 stars 12 forks source link

Code from example simple_setup fails to compile #99

Open GMZwinge opened 1 month ago

GMZwinge commented 1 month ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Run bolt plan run test_voxpupuli_puppet_k8s::myplan --target <host> --user <user> --password <password> type=<type> in this repo, where <type> can be either controller or worker.

Once I get this working, I will provide a PR to fix the example.

What are you seeing

With type=controller, the error is:

  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  

With type=worker, the error is:

  Apply failed to compile for <host>: Class[Profile::K8s::Worker]:
    parameter 'control_plane_url' expects a match for Stdlib::HTTPUrl = Pattern[/(?i:\Ahttps?:\/\/.*\z)/], got Undef
    parameter 'k8s_version' expects a String value, got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 8, column: 5)    

What behaviour did you expect instead

There is no failure.

Output log

With type=controller, the output is:

Starting: plan test_voxpupuli_puppet_k8s::myplan
Start test_voxpupuli_puppet_k8s::myplan.
Starting: install puppet and gather facts on <host>
Finished: install puppet and gather facts with 0 failures in 7.42 sec
Starting: apply catalog on <host>
Failed on <host>:
  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  
Finished: apply catalog with 1 failure in 5.02 sec
Finished: plan test_voxpupuli_puppet_k8s::myplan in 12.44 sec
Failed on <host>:
  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  
Failed on 1 target: <host>
Ran on 1 target

With type=worker, the output is:

Starting: plan test_voxpupuli_puppet_k8s::myplan
Start test_voxpupuli_puppet_k8s::myplan.
Starting: install puppet and gather facts on <host>
Finished: install puppet and gather facts with 0 failures in 7.63 sec
Starting: apply catalog on <host>
Failed on <host>:
  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  
Finished: apply catalog with 1 failure in 4.8 sec
Finished: plan test_voxpupuli_puppet_k8s::myplan in 12.44 sec
Failed on <host>:
  Apply failed to compile for <host>: Class[Profile::K8s::Controller]: parameter 'container_manager' expects a match for K8s::Container_runtimes = Enum['containerd', 'crio'], got Undef (file: /test_voxpupuli_puppet_k8s/manifests/my_manifest.pp, line: 6, column: 5)  
Failed on 1 target: <host>
Ran on 1 target

Any additional information you'd like to impart

GMZwinge commented 3 weeks ago

I can workaround the issue by adding the container runtime as a data and look it up for both controller and worker. See this commit. Is there a better way?

GMZwinge commented 3 weeks ago

After applying a similar workaround for other common data and turning off puppetdb discovery, it now gives error like this when applying to the controller:

Apply failed to compile for kubernetes: Class[K8s::Server::Resources::Bootstrap]: parameter 'secret' expects a value of type Undef or Sensitive[K8s::Bootstrap_token], got String (file: /test_voxpupuli_puppet_k8s/.modules/k8s/manifests/server/resources.pp, line: 66, column: 5)