Kubernetes Deep Dive

Sign Up Free or Log In to participate!

kubectl apply command error

Hi Nigel,

Was following your demo of Kubernetes, where you deployed 3 node cluster and deploys manifest file ping-deploy.yml (from Github).

I fetched file on GKE engine and executed the same command, but getting the following error:

atulrd@cloudshell:~ (kubernetes-demo-project-230110)$ kubectl apply -f .ping-deploy.yml

error: the path ".ping-deploy.yml" does not exist

Pls, note file is available on the same path (/home/atulrd) from where the command is executed.

2. If I execute the following command:

atulrd@cloudshell:~ (kubernetes-demo-project-230110)$ kubectl apply -f ping-deploy.yml
error: error converting YAML to JSON: yaml: line 528: mapping values are not allowed in this context

Can you pls help here?




Try ./ rather than . in the command.


Can we see line 528 of the file please? Maybe with a few before and after it for context.

3 Answers

as per @rk295 – Nigel is using PS hence the . if you’re using Linux based CLI then its ./

you can just do ”’kubectl apply -f ping-deploy.yml”’

if you are in the same directory as the file regardless if you are in Windows/Linux/Mac.

if you are in Linux/Mac and not in the same directory, then you have to specify the path either a relative/absolute the Linux/Mac way using forward slashes "/" and in windows using the backward slash ""

As stated by the other guys, Linux uses forward slashes "/" instead of backslashes "".  Re the YAML problem… I’ve had a look at the YAML file in the coure’s GH repo and there’s nowhere near 528 lines. Is it possible that there’s been a formatting error when "fetching" the file to the cloudshell?

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?