Error when health checking Kubernetes target

When health checking the kubernetes deploy target I get this error:

Check k8s-test health
Ran for 3 seconds
March 17th 2021 16:45:27Info
Starting health check for a limited set of machines. 
March 17th 2021 16:45:27Info
Performing health check on 1 machine. 
March 17th 2021 16:45:30Fatal
The health check failed. One or more machines were not available. 
Check deployment target: k8s-test
Ran for 3 seconds
March 17th 2021 16:45:30Error
NotSpecified: Could not find kubectl. Make sure kubectl is on the PATH. See https://g.octopushq.com/KubernetesTarget for more information. 
March 17th 2021 16:45:30Error
At C:\Octopus\Work\20210317154528-103-8\Octopus.KubectlPowershellContext.ps1:314 char:1 
March 17th 2021 16:45:30Error
+ SetupContext 
March 17th 2021 16:45:30Error
+ ~~~~~~~~~~~~ 
March 17th 2021 16:45:30Error
at SetupContext, C:\Octopus\Work\20210317154528-103-8\Octopus.KubectlPowershellContext.ps1: line 160 
March 17th 2021 16:45:30Error
at <ScriptBlock>, C:\Octopus\Work\20210317154528-103-8\Octopus.KubectlPowershellContext.ps1: line 314 
March 17th 2021 16:45:30Error
at <ScriptBlock>, C:\Octopus\Work\20210317154528-103-8\Bootstrap.Octopus.KubectlPowershellContext.ps1: line 1096 
March 17th 2021 16:45:30Error
at <ScriptBlock>, <No file>: line 1 
March 17th 2021 16:45:30Error
at <ScriptBlock>, <No file>: line 1 
March 17th 2021 16:45:30Fatal
The remote script failed with exit code 1 
Summary
Ran for 0 seconds
March 17th 2021 16:45:30Info
Unhealthy: 
March 17th 2021 16:45:30Info
 - k8s-test at https://IPADDRESS, error: The remote script failed with exit code 1 
March 17th 2021 16:45:30Fatal
One or more machines were not available. Please see the output Log for details. 
NotSpecified: Could not find kubectl. Make sure kubectl is on the PATH. See https://g.octopushq.com/KubernetesTarget for more information. 

As you can see it says I need kubectl installed on the Octopus Server with the right PATH. I have done this correctly but still I get this error… Maybe when this is fixed i get a more specific log. Advice would be appreciated!

Hi @sjoerdroodenburg!

If you added a new addition to your path variable, it’s likely that this hasn’t updated, as the healthchecks, and all of the deployments run as child processes of the Tentacle (or Server) service, which has the environment variables at the time it was started.

If you restart the Tentacle (or Server, depending where you’re running this) service, do you have better luck when attempting this?

Hey Justin,

Still no luck after restarting Octopus Service.

Hi @sjoerdroodenburg,

It would be worth checking what user the Octopus Deploy service is running under, logging in as that user on the server and testing in Powershell whether you have access to kubectl outside of Octopus as the user Octopus runs as.

Regards,
Paul

1 Like

Fixed. It had to do with the services user like @paul.calvert said. Changing it to my local user fixed the issue.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.