Skip to content

Commit 252bcf6

Browse files
Tim Bannisterdivya-mohan0209
andcommitted
Adapt Kubernetes basics tutorials for local use
Avoid relying on Katacoda. Co-authored-by: Divya Mohan <[email protected]>
1 parent 3e51968 commit 252bcf6

File tree

8 files changed

+358
-67
lines changed

8 files changed

+358
-67
lines changed

content/en/docs/contribute/style/style-guide.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -385,29 +385,6 @@ The output is:
385385
Beware.
386386
{{< /warning >}}
387387

388-
### Katacoda Embedded Live Environment
389-
390-
This button lets users run Minikube in their browser using the Katacoda Terminal.
391-
It lowers the barrier of entry by allowing users to use Minikube with one click instead of going through the complete
392-
Minikube and Kubectl installation process locally.
393-
394-
The Embedded Live Environment is configured to run `minikube start` and lets users complete tutorials in the same window
395-
as the documentation.
396-
397-
{{< caution >}}
398-
The session is limited to 15 minutes.
399-
{{< /caution >}}
400-
401-
For example:
402-
403-
```
404-
{{</* kat-button */>}}
405-
```
406-
407-
The output is:
408-
409-
{{< kat-button >}}
410-
411388
## Common Shortcode Issues
412389

413390
### Ordered Lists

content/en/docs/tutorials/hello-minikube.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ Pod and restarts the Pod's Container if it terminates. Deployments are the
9898
recommended way to manage the creation and scaling of Pods.
9999

100100
1. Use the `kubectl create` command to create a Deployment that manages a Pod. The
101-
Pod runs a Container based on the provided Docker image.
101+
Pod runs a Container based on the provided Docker image.
102102

103103
```shell
104+
# Run a test container image that includes a webserver
104105
kubectl create deployment hello-node --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- /agnhost netexec --http-port=8080
105106
```
106107

@@ -162,7 +163,7 @@ Kubernetes [*Service*](/docs/concepts/services-networking/service/).
162163
The `--type=LoadBalancer` flag indicates that you want to expose your Service
163164
outside of the cluster.
164165

165-
The application code inside the image `registry.k8s.io/echoserver` only listens on TCP port 8080. If you used
166+
The application code inside the test image only listens on TCP port 8080. If you used
166167
`kubectl expose` to expose a different port, clients could not connect to that other port.
167168

168169
2. View the Service you created:
@@ -236,7 +237,7 @@ The minikube tool includes a set of built-in {{< glossary_tooltip text="addons"
236237
The 'metrics-server' addon is enabled
237238
```
238239
239-
3. View the Pod and Service you created:
240+
3. View the Pod and Service you created by installing that addon:
240241
241242
```shell
242243
kubectl get pod,svc -n kube-system
@@ -286,7 +287,7 @@ kubectl delete service hello-node
286287
kubectl delete deployment hello-node
287288
```
288289
289-
Stop the minikube cluster:
290+
Stop the Minikube cluster
290291
291292
```shell
292293
minikube stop

content/en/docs/tutorials/kubernetes-basics/create-cluster/cluster-intro.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
title: Using Minikube to Create a Cluster
33
weight: 10
4+
description: |-
5+
Learn what a Kubernetes cluster is.
6+
Learn what Minikube is.
7+
Start a Kubernetes cluster.
48
---
59

610
<!DOCTYPE html>
@@ -20,7 +24,7 @@ <h3>Objectives</h3>
2024
<ul>
2125
<li>Learn what a Kubernetes cluster is.</li>
2226
<li>Learn what Minikube is.</li>
23-
<li>Start a Kubernetes cluster using an online terminal.</li>
27+
<li>Start a Kubernetes cluster on your computer.</li>
2428
</ul>
2529
</div>
2630

@@ -84,18 +88,16 @@ <h2 style="color: #3771e3;">Cluster Diagram</h2>
8488
<div class="col-md-8">
8589
<p>When you deploy applications on Kubernetes, you tell the control plane to start the application containers. The control plane schedules the containers to run on the cluster's nodes. <b>The nodes communicate with the control plane using the <a href="/docs/concepts/overview/kubernetes-api/">Kubernetes API</a></b>, which the control plane exposes. End users can also use the Kubernetes API directly to interact with the cluster.</p>
8690

87-
<p>A Kubernetes cluster can be deployed on either physical or virtual machines. To get started with Kubernetes development, you can use Minikube. Minikube is a lightweight Kubernetes implementation that creates a VM on your local machine and deploys a simple cluster containing only one node. Minikube is available for Linux, macOS, and Windows systems. The Minikube CLI provides basic bootstrapping operations for working with your cluster, including start, stop, status, and delete. For this tutorial, however, you'll use a provided online terminal with Minikube pre-installed.</p>
91+
<p>A Kubernetes cluster can be deployed on either physical or virtual machines. To get started with Kubernetes development, you can use Minikube. Minikube is a lightweight Kubernetes implementation that creates a VM on your local machine and deploys a simple cluster containing only one node. Minikube is available for Linux, macOS, and Windows systems. The Minikube CLI provides basic bootstrapping operations for working with your cluster, including start, stop, status, and delete.</p>
92+
93+
<p>Now that you know more about what Kubernetes is, visit <a href="/docs/tutorials/hello-minikube/">Hello Minikube</a>
94+
to try this out on your computer.</p>
8895

89-
<p>Now that you know what Kubernetes is, let's go to the online tutorial and start our first cluster!</p>
9096

9197
</div>
9298
</div>
93-
<br>
94-
9599
<div class="row">
96-
<div class="col-md-12">
97-
<a class="btn btn-lg btn-success" href="/docs/tutorials/kubernetes-basics/create-cluster/cluster-interactive/" role="button">Start Interactive Tutorial <span class="btn__next"></span></a>
98-
</div>
100+
<p>Once you've done that, move on to <a href="/docs/tutorials/kubernetes-basics/deploy-app/deploy-intro/">Using <tt>kubectl</tt> to create a Deployment</a>.</p>
99101
</div>
100102

101103
</main>

content/en/docs/tutorials/kubernetes-basics/deploy-app/deploy-intro.html

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
title: Using kubectl to Create a Deployment
33
weight: 10
4+
description: |-
5+
Learn about application Deployments.
6+
Deploy your first app on Kubernetes with kubectl.
47
---
58

69
<!DOCTYPE html>
@@ -14,26 +17,25 @@
1417
<main class="content">
1518

1619
<div class="row">
17-
1820
<div class="col-md-8">
1921
<h3>Objectives</h3>
20-
<ul>
21-
<li>Learn about application Deployments.</li>
22-
<li>Deploy your first app on Kubernetes with kubectl.</li>
23-
</ul>
24-
</div>
22+
<ul>
23+
<li>Learn about application Deployments.</li>
24+
<li>Deploy your first app on Kubernetes with kubectl.</li>
25+
</ul>
26+
</div>
2527

2628
<div class="col-md-8">
2729
<h3>Kubernetes Deployments</h3>
2830
<p>
29-
Once you have a running Kubernetes cluster, you can deploy your containerized applications on top of it.
30-
To do so, you create a Kubernetes <b>Deployment</b> configuration. The Deployment instructs Kubernetes
31+
Once you have a <a href="/docs/tutorials/kubernetes-basics/create-cluster/cluster-intro/">running Kubernetes cluster</a>, you can deploy your containerized applications on top of it.
32+
To do so, you create a Kubernetes <b>Deployment</b>. The Deployment instructs Kubernetes
3133
how to create and update instances of your application. Once you've created a Deployment, the Kubernetes
3234
control plane schedules the application instances included in that Deployment to run on individual Nodes in the
3335
cluster.
3436
</p>
3537

36-
<p>Once the application instances are created, a Kubernetes Deployment Controller continuously monitors those instances. If the Node hosting an instance goes down or is deleted, the Deployment controller replaces the instance with an instance on another Node in the cluster. <b>This provides a self-healing mechanism to address machine failure or maintenance.</b></p>
38+
<p>Once the application instances are created, a Kubernetes Deployment controller continuously monitors those instances. If the Node hosting an instance goes down or is deleted, the Deployment controller replaces the instance with an instance on another Node in the cluster. <b>This provides a self-healing mechanism to address machine failure or maintenance.</b></p>
3739

3840
<p>In a pre-orchestration world, installation scripts would often be used to start applications, but they did not allow recovery from machine failure. By both creating your application instances and keeping them running across Nodes, Kubernetes Deployments provide a fundamentally different approach to application management. </p>
3941

@@ -72,7 +74,7 @@ <h2 style="color: #3771e3;">Deploying your first app on Kubernetes</h2>
7274
<div class="row">
7375
<div class="col-md-8">
7476

75-
<p>You can create and manage a Deployment by using the Kubernetes command line interface, <b>Kubectl</b>. Kubectl uses the Kubernetes API to interact with the cluster. In this module, you'll learn the most common Kubectl commands needed to create Deployments that run your applications on a Kubernetes cluster.</p>
77+
<p>You can create and manage a Deployment by using the Kubernetes command line interface, <b>kubectl</b>. Kubectl uses the Kubernetes API to interact with the cluster. In this module, you'll learn the most common Kubectl commands needed to create Deployments that run your applications on a Kubernetes cluster.</p>
7678

7779
<p>When you create a Deployment, you'll need to specify the container image for your application and the number of replicas that you want to run. You can change that information later by updating your Deployment; Modules <a href="/docs/tutorials/kubernetes-basics/scale/scale-intro/">5</a> and <a href="/docs/tutorials/kubernetes-basics/update/update-intro/">6</a> of the bootcamp discuss how you can scale and update your Deployments.</p>
7880

@@ -91,18 +93,69 @@ <h2 style="color: #3771e3;">Deploying your first app on Kubernetes</h2>
9193
<div class="col-md-8">
9294
<p>
9395
For your first Deployment, you'll use a hello-node application packaged in a Docker container that uses NGINX to echo back all the requests. (If you didn't already try creating a hello-node application and deploying it using a container, you can do that first by following the instructions from the <a href="/docs/tutorials/hello-minikube/">Hello Minikube tutorial</a>).
94-
<p>
95-
96-
<p>Now that you know what Deployments are, let's go to the online tutorial and deploy our first app!</p>
96+
<p>You will need to have installed kubectl as well. If you need to install it, visit <a href="/docs/tasks/tools/#kubectl">install tools</a>.</p>
97+
<p>Now that you know what Deployments are, let's deploy our first app!</p>
9798
</div>
9899
</div>
99100
<br>
100101

102+
<div class="row">
103+
<div class="col-md-8">
104+
<h3>kubectl basics</h3>
105+
<p>The common format of a kubectl command is: <code>kubectl <i>action resource</i></code></p>
106+
<p>This performs the specified <em>action</em> (like create, describe or delete) on the specified <em>resource</em> (like <tt>node</tt> or <tt>deployment</tt>). You can use <code>-<span />-help</code> after the subcommand to get additional info about possible parameters (for example: <code>kubectl get nodes --help</code>).</p>
107+
<p>Check that kubectl is configured to talk to your cluster, by running the <b><code>kubectl version</code></b> command.</p>
108+
<p>Check that kubectl is installed and you can see both the client and the server versions.</p>
109+
<p>To view the nodes in the cluster, run the <b><code>kubectl get nodes</code></b> command.</p>
110+
<p>You see the available nodes. Later, Kubernetes will choose where to deploy our application based on Node available resources.</p>
111+
</div>
112+
</div>
101113
<div class="row">
102114
<div class="col-md-12">
103-
<a class="btn btn-lg btn-success" href="/docs/tutorials/kubernetes-basics/deploy-app/deploy-interactive/" role="button">Start Interactive Tutorial <span class="btn__next"></span></a>
115+
<h3>Deploy an app</h3>
116+
<p>Let’s deploy our first app on Kubernetes with the <code>kubectl create deployment</code> command. We need to provide the deployment name and app image location (include the full repository url for images hosted outside Docker hub).</p>
117+
<p><b><code>kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1</code></b></p>
118+
<p>Great! You just deployed your first application by creating a deployment. This performed a few things for you:</p>
119+
<ul>
120+
<li>searched for a suitable node where an instance of the application could be run (we have only 1 available node)</li>
121+
<li>scheduled the application to run on that Node</li>
122+
<li>configured the cluster to reschedule the instance on a new Node when needed</li>
123+
</ul>
124+
<p>To list your deployments use the <code>kubectl get deployments</code> command:</p>
125+
<p><b><code>kubectl get deployments</code></b></p>
126+
<p>We see that there is 1 deployment running a single instance of your app. The instance is running inside a container on your node.</p>
104127
</div>
105128
</div>
129+
<div class="row">
130+
<div class="col-md-12">
131+
<h3>View the app</h3>
132+
<p>Pods that are running inside Kubernetes are running on a private, isolated network.
133+
By default they are visible from other pods and services within the same kubernetes cluster, but not outside that network.
134+
When we use <code>kubectl</code>, we're interacting through an API endpoint to communicate with our application.</p>
135+
<p>We will cover other options on how to expose your application outside the kubernetes cluster in Module 4.</p>
136+
<p>The <code>kubectl</code> command can create a proxy that will forward communications into the cluster-wide, private network. The proxy can be terminated by pressing control-C and won't show any output while its running. </p>
137+
<p><strong>You need to open a second terminal window to run the proxy.</strong></p>
138+
<p><b><code>kubectl proxy</b></code>
139+
<p>We now have a connection between our host (the online terminal) and the Kubernetes cluster. The proxy enables direct access to the API from these terminals.</p>
140+
<p>You can see all those APIs hosted through the proxy endpoint. For example, we can query the version directly through the API using the <code>curl</code> command:</p>
141+
<p><b><code>curl http://localhost:8001/version</code></b></p>
142+
<div class="alert alert-info note callout" role="alert"><strong>Note:</strong> If Port 8001 is not accessible, ensure that the <code>kubectl proxy</code> that you started above is running in the second terminal.</div>
143+
<p>The API server will automatically create an endpoint for each pod, based on the pod name, that is also accessible through the proxy.</p>
144+
<p>First we need to get the Pod name, and we'll store in the environment variable <tt>POD_NAME</tt>:</p>
145+
<p><b><code>export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')</code></b><br />
146+
<b><code>echo Name of the Pod: $POD_NAME</code></b></p>
147+
<p>You can access the Pod through the proxied API, by running:</p>
148+
<p><b><code>curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/</code></b></p>
149+
<p>In order for the new Deployment to be accessible without using the proxy, a Service is required which will be explained in the next modules.</p>
150+
</div>
151+
152+
</div>
153+
<div class="row">
154+
<p>
155+
Once you're ready, move on to <a href="/docs/tutorials/kubernetes-basics/explore/explore-intro/" title="Viewing Pods and Nodes">Viewing Pods and Nodes</a>.</p>
156+
</p>
157+
</div>
158+
106159

107160
</main>
108161

0 commit comments

Comments
 (0)