Skip to content

New getting started blog post#14970

Merged
k8s-ci-robot merged 7 commits intokubernetes:masterfrom
JasonHaley:patch-1
Jul 23, 2019
Merged

New getting started blog post#14970
k8s-ci-robot merged 7 commits intokubernetes:masterfrom
JasonHaley:patch-1

Conversation

@JasonHaley
Copy link
Copy Markdown
Contributor

I'd like to submit a blog post for the kubernetes.io blog targeted to people just getting started with Kubernetes. I myself am still new to it but want to start writing more to share what I am learning and help others along the way. My point of view is a little different than most people who post on the kubernetes.io blog since I am an independent consultant and I also work mostly with Microsoft products - so some of my resources are from Microsoft which seems rare for some reason in most Kubernetes blog posts I find on the web.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remember to delete this note before submitting your pull request.

For pull requests on 1.15 Features: set Milestone to 1.15 and Base Branch to dev-1.15

For pull requests on Chinese localization, set Base Branch to release-1.14

For pull requests on Korean Localization: set Base Branch to dev-1.14-ko.<latest team milestone>

If you need Help on editing and submitting pull requests, visit:
https://kubernetes.io/docs/contribute/start/#improve-existing-content.

If you need Help on choosing which branch to use, visit:
https://kubernetes.io/docs/contribute/start#choose-which-git-branch-to-use.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I'd like to submit a blog post for the kubernetes.io blog targeted to people just getting started with Kubernetes. I myself am still new to it but want to start writing more to share what I am learning and help others along the way. My point of view is a little different than most people who post on the kubernetes.io blog since I am an independent consultant and I also work mostly with Microsoft products - so some of my resources are from Microsoft which seems rare for some reason in most Kubernetes blog posts I find on the web.
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @JasonHaley!

It looks like this is your first PR to kubernetes/website 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/website has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/blog Issues or PRs related to the Kubernetes Blog subproject language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Jun 18, 2019
@netlify
Copy link
Copy Markdown

netlify bot commented Jun 19, 2019

Deploy preview for kubernetes-io-master-staging ready!

Built with commit f675b07

https://deploy-preview-14970--kubernetes-io-master-staging.netlify.com

@JasonHaley
Copy link
Copy Markdown
Contributor Author

I have 4 images to include but didn't get them included on the PR. I couldn't figure out how to add the images, I don't see a directory in the repo that has images from the other blogs. How can I' get the images added? /assign @kbarnard10

@zhangqx2010
Copy link
Copy Markdown
Contributor

@JasonHaley Thanks for your PR.You can add images to /static/images/blog.

I added the image files and changed the paths in the markdown to /static/images/blog/...
@JasonHaley
Copy link
Copy Markdown
Contributor Author

I added the images and modified the markdown, but I believe the md and images may not be in the right location now (i think they are off the root of the repo). Sorry that - this is my first pull request on a public repo, so I'm learning my way here. Is there something I need to do to fix the location now? Should I just start over with a new pull request? /assign @zacharysarah

@castrojo
Copy link
Copy Markdown
Member

I can't take a look at this until next week but would be happy to help get your images and links sorted.

@JasonHaley
Copy link
Copy Markdown
Contributor Author

JasonHaley commented Jun 19, 2019 via email

@zhangqx2010
Copy link
Copy Markdown
Contributor

@JasonHaley Dont't worry. This guide may help a little. And I think the file name may need some change.

@kbarnard10 kbarnard10 requested a review from mrbobbytables June 20, 2019 02:58
@kbarnard10 kbarnard10 self-assigned this Jun 20, 2019
@JasonHaley
Copy link
Copy Markdown
Contributor Author

Yeah I read through that guide which is where I messed up. the "Create new file" button works great but I think I could have used some direction at that point for what to do with any images. Once I created the initial PR, I couldn't figure out the multiple files after the fact.

@zhangqx2010
Copy link
Copy Markdown
Contributor

Oh I see. It's better to add some guide for the image location.

@@ -0,0 +1,217 @@
---
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file location needs to be changed. 😄

And help needed from native English speaker to review the content.

@zhangqx2010
Copy link
Copy Markdown
Contributor

@JasonHaley I just created a PR to your repo to fix the path. Please check and do the merge.

@JasonHaley
Copy link
Copy Markdown
Contributor Author

I merged @zhangqx2010 image path fixes. /assign @kbarnard10

@zhangqx2010
Copy link
Copy Markdown
Contributor

@JasonHaley
You need add date content for your blog so that your article will appear on the netlify preivew:
e.g.

---
layout: blog
title: Get started with Kubernetes (using Python)
date: 2019-06-20  


There are only two files in this directory. If you look at the main.py file, you’ll see the application prints out a hello message. You can learn more about Flask on the [Flask website](http://flask.pocoo.org/).

```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. If you wanted to have this highlighted as Python you could do that (append python to this line). What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bad idea. It would make sense that someone may want to also learn more about Python, though originally I didn't really want to highlight a specific language. My original title didn't have it in there either but I got some feedback that it might make sense to put it in the title.

Added a date to get it on netlify preview
Copy link
Copy Markdown
Contributor Author

@JasonHaley JasonHaley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a date in the header. Not sure what the next step is. /assign @kbarnard10

Copy link
Copy Markdown
Contributor

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JasonHaley, great beginner's writeup, thank you! I've left a few comments/suggestions inline, but nothing too major.

```
pip install -r requirements.txt
python main.py
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may wish to put a note here mentioning that running pip install isn't recommended for most scenarios. Instead, it's more common practice to use virtualenv (or pyenv) and install dependencies within a virtual environment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, once again that shows how much of a beginner I am in Python. Thank you for your review notes, they really add to the quality of the blog!

3. Set the working directory to that new app directory.
4. Copy the local directory’s contents to that new folder into the image.
5. Run the pip installer (just like we did earlier) to pull the requirements into the image.
6. Configure port 5000 to be open.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really that EXPOSE "opens" a port or actually that EXPOSE performs any action at all. Rather, it serves more as documentation to the user of the image that the service daemon running in the image is listening on a particular port. This allows the user of the image to set up a port redirection on the host by calling docker run -P or docker run -p.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, that totally shows how much of a beginner I am - I wasn't aware of that it really doesn't do anything in the Dockerfile.

### Create an image
At your command line or shell, in the hello-python/app directory, build the image with the following command:
```
docker build -f Dockerfile -t hello-python:latest .
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth mentioning in a note here that using the :latest tag on an image can be error-prone. See here for more information: https://container-solutions.com/docker-latest-confusion/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a note about that and pointed to the link, but I'm not sure if it belongs. See what you think.


Now let’s have it run the application. Create a file named deployment.yaml and add the following contents to it and then save it:

```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the following here to enable syntax highlighting:

```yaml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, I didn't know that.


Make sure it is using the Docker for Desktop context by running the following:
```
kubectl config use-context docker-for-desktop
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is needed or recommended for readers not using Windows (or Mac?). Perhaps worth prefacing the above with "If you are running on Windows or Mac, make sure.."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm definitely coming from a windows point of view, so thanks that helps broaden the message.

3. Create a deployment and run the application in Kubernetes

## Prerequisites
* [Docker Desktop with Kubernetes](https://www.docker.com/products/kubernetes) installed (see end of blog for enabling Kubernetes)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to just list "A Kubernetes service" here, possibly with a link to the various installation methods here: https://kubernetes.io/docs/setup/.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that makes sense I work that in. One of the ideas I had with this blog was get across the message that if you are already working with Docker, it is easy to also start learning Kubernetes (instead of Docker Swarm) with the tools you already have.

```
<img src="/images/blog/get-started-with-kubernetes-using-python/kubectl-get-pods.png" alt="Pod listing" />

Now navigate to http://localhost:6001, and you should see the “Hello form Python!” message.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The load balancer is exposed on port 6000 in the configuration above, not 6001.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, nice catch!

Copy link
Copy Markdown
Member

@mrbobbytables mrbobbytables left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty solid, one small suggestion and I'd +1 @jaypipes comments.

type: LoadBalancer

---
apiVersion: apps/v1beta1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
apiVersion: apps/v1beta1
apiVersion: apps/v1

With the upcoming deprecation of apps/v1beta1 I would suggest using the stable v1 api

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I wasn't aware of that.

@JasonHaley
Copy link
Copy Markdown
Contributor Author

JasonHaley commented Jun 27, 2019

I worked in some good fixes from @mrbobbytables and @jaypipes.

/assign @kbarnard10 @castrojo @vonguard

@JasonHaley
Copy link
Copy Markdown
Contributor Author

Any update on this?

@tengqm
Copy link
Copy Markdown
Contributor

tengqm commented Jul 8, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 8, 2019
@JasonHaley
Copy link
Copy Markdown
Contributor Author

@castrojo or @vonguard any chance you can take a look at this soon?

@vonguard
Copy link
Copy Markdown
Contributor

vonguard commented Jul 16, 2019 via email

@vonguard
Copy link
Copy Markdown
Contributor

/lgtm

@JasonHaley
Copy link
Copy Markdown
Contributor Author

@vonguard Thanks! Next questions is how does it get approved?

@JasonHaley
Copy link
Copy Markdown
Contributor Author

/assign @kbarnard10

…-07-23-get-started-with-kubernetes-using-python.md
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 23, 2019
@kbarnard10
Copy link
Copy Markdown
Contributor

/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kbarnard10

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 23, 2019
@kbarnard10
Copy link
Copy Markdown
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 23, 2019
@k8s-ci-robot k8s-ci-robot merged commit d18d07a into kubernetes:master Jul 23, 2019
@JasonHaley
Copy link
Copy Markdown
Contributor Author

@kbarnard10 it seems the formatting is off when getting translated into html. Looks like a blockquote isn't getting closed right before the heading "Run locally".

It shows fine in markdown here: https://github.com/kubernetes/website/blob/master/content/en/blog/_posts/2019-07-23-get-started-with-kubernetes-using-python.md

But the code formatting gets inverted on this one:
https://kubernetes.io/blog/2019/07/23/get-started-with-kubernetes-using-python/

Do you know what I need to do to fix it? or do you know what component is used to convert from markdown to html? I can try and figure it out if so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/blog Issues or PRs related to the Kubernetes Blog subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants