nigelpoulton / TheK8sBook

YAML files for use with The Kubernetes Book
822 stars 665 forks source link

shield-app.yml and namespace #35

Closed MichaelLiss closed 1 year ago

MichaelLiss commented 1 year ago

Hi

I am running through the examples and tried this as directed in the book

I am in the chapter dealing with namespaces and was told to do this:

kubectl apply -f shield-app.yml

After I ran the command, I got this:

Error from server (NotFound): error when creating "shield-app.yml": namespaces "shield" not found

I asked a colleague and they said the namespace MUST be created first... so I did this:

kubectl create namespace shield

then ran the original yml command again... this time with success and a warning

Warning: resource serviceaccounts/default is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
serviceaccount/default configured
service/the-bus created
pod/triskelion created
MichaelLiss commented 1 year ago

Additionally... it would have been nice to have "curl command" example to connect to the local host...

nigelpoulton commented 1 year ago

Hi @MichaelLiss

That's a great idea for the curl example. I'll get that added in the 2024 edition of the book.

Re the missing Namespace issue... I've had a look at this and it looks like you're running the example from page 72 in the 2023 edition of the book.

I think you've not completed the earlier step on page 70 which runs the following command to pre-create the namespace:

kubectl apply -f shield-ns.yml

You also won't get the missing annotation warning if you run that command first to deploy the Namespace declaratively.

I've made a note of this and will verify it all for the 2024 edition and if necessary I'll add a comment to clarify.

Nigel