cloudnativedevops / demo

Simple demonstration app for 'Cloud Native Devops'
MIT License
799 stars 517 forks source link

Chapter 2 kubectl deployment doesn't work on a real cluster #27

Closed dwschulze closed 4 years ago

dwschulze commented 4 years ago

In chapter 2 the command you show to deploy the myhello application gives a different output than you show when I run it on the master of a 3 node cluster:

$ kubectl run demo --image=dwschulze/myhello --port=9999 --labels app=demo
pod/demo created

The output you show is:

deployment.apps "demo" created

When I try to do the port forwarding it fails because I have no deployments.

Do I need a deployment.yaml to deploy this onto a real cluster, or is there a different kubectl command I use?

dwschulze commented 4 years ago

This is the command that is needed on a cluster:

$ sudo kubectl create deployment demo --image=demo

Maybe on a single node too?

domingusj commented 4 years ago

@dwschulze thanks for opening an issue!

Are you by chance running version 1.18 of Kubernetes?

I think the issue you are experiencing could be due to a change in the 1.18 release. The latest release of Kubernetes back when the book was published was 1.10 or 1.11 so this could be a case where Kubernetes has changed something and our example no longer works with newer versions.

After searching docs between 1.17 and 1.18 it looks like kubectl run no longer creates a Deployment:

1.17 docs (https://v1-17.docs.kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run) Creates a deployment or job to manage the created container(s).

1.18 docs (https://v1-18.docs.kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run) Create and run a particular image in a pod.

Let us know if that lines up with your current version and we'll get an update to the Known Issues section in the demo repo with an updated example.

dwschulze commented 4 years ago

I'm running 1.18.2. Should probably go into the errata too.

domingusj commented 4 years ago

PR merged with updated Known Issue in the README.

(Not sure why GitHub labeled the PR as "Closed" instead of "Merged").

Also submitted errata to O'Reilly.

Thank you @dwschulze for catching this!