-
Notifications
You must be signed in to change notification settings - Fork 49
cli/cmd: implement kubeconfig fallback to Terraform state #701
Conversation
It seems caching is more complex than I thought, as the optimal sequence of execution is against our abstraction. What we need:
And what we have right now:
|
127725b
to
9a4c8bc
Compare
af5faa8
to
0676578
Compare
0676578
to
b5d3d64
Compare
b5d3d64
to
44c3c0c
Compare
Rebased to resolve conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
This failed as we want: $ lokoctl component apply
WARN[0000] Kubeconfig file not found in assets directory, pulling kubeconfig from Terraform state, this might be slow. Run 'lokoctl cluster apply' to fix it. args="[]" command="lokoctl component apply"
INFO[0004] Executing step "initialize Terraform" phase=infrastructure
You can find the logs in "assets/terraform/logs/299669.log"
FATA[0005] Error in finding kubeconfig file: reading kubeconfig file content from Terraform state: failed getting Terraform output for key "kubeconfig": exit status 1 args="[]" command="lokoctl component apply" $ cat assets/terraform/logs/299669.log
Initializing modules...
Initializing the backend...
Initializing provider plugins...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary. Can we give more informational message to the user? |
Hmm, should we replace top-level message ( Something like |
@invidian that should do for now :-) It is better than the terraform one. |
Maybe we can keep existing message in debug verbosity? |
Sounds ok @invidian |
As part of #623, which is about using kubeconfig file content rather than kubeconfig path around, this commits adds Terraform output with content of kubeconfig file, which can be then pulled during execution using 'terraform output' command. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
As number of tests we have has grown, currently running it with verbose makes it very hard to find which test failed. Removing '-v' flag improves that a bit. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
Closes #608. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
44c3c0c
to
7b8e721
Compare
😕 I had to add |
7b8e721
to
f35178e
Compare
f35178e
to
2b9507a
Compare
Can you please update the docs again, it's failing because of the init function change |
So debug messages can be displayed if --debug flag is specified. This is useful for printing not very UX friendly messages to the user if some issue occurs. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
For users, we display nice error message which suggests running 'lokoctl cluster apply', while in debug logs we print exact message. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
2b9507a
to
b2d084a
Compare
🤦 done 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest lgtm
Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
This failed as follows: $ lokoctl health --kubeconfig-file $HOME/.kube/config
ERRO[0000] <nil>: no platform configured; args="[]" command="lokoctl health"
FATA[0000] Suitable kubeconfig file not found. Did you run 'lokoctl cluster apply' ? args="[]" command="lokoctl health"
$ lokoctl version
v0.3.0-207-gf7f5eded9
$ ll
.rw-rw-r--@ 35 surajd 3 Sep 12:45 foobar.lokocfg
$ cat foobar.lokocfg
component "prometheus-operator" {}
|
This is as intended. |
Why do we have a
|
Because it's a global flag... :( And yes, entire CLI code should probably be reworked to clean those things up.. |
Other commands don't really need this flag and commands like 'cluster apply' or 'health' should only be executed in the scope of L8e cluster, so they shouldn't allow overriding used kubeconfig file, as it might be very confusing. Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
aa9c70f
to
8fa88da
Compare
@surajssd I pushed the fix with moving |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified the lokoctl health
functionality works.
This PR includes commits from #631, please review this one first and don't leave commit comments for this PR here.
TODO:
lokoctl health
is now slower, as on every run, it initializes the Terraform and reads the output. Should we try to read file from assets dir first and then fallback to Terraform output? Maybe we should cache somehow thekubeconfig
file content?Closes #608
Signed-off-by: Mateusz Gozdek mateusz@kinvolk.io