You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To open the dashboard in your browser when using Minikube to run your Kubernetes cluster, run the following command:
370
373
371
374
`minikube dashboard`
375
+
376
+
### Pods
377
+
378
+
Pods and other Kubernetes resources are usually created by posting a JSON or YAML manifest to the Kubernetes REST API endpoint. Also, you can use other, simpler ways of creating resources, such as the **kubectl run** command, but they usually only allow you to configure a limited set of properties, not all. Additionally, defining all your Kubernetes objects from YAML files makes it possible to store them in a version control system, with all the benefits it brings.
379
+
380
+
#### Examining a YAML descriptor of an existing pod
381
+
382
+
You’ll use the **kubectl get** command with the **-o yaml** option to get the whole YAML definition of the pod, or you can use **-o json** to get the whole JSON definition as shown in the following listing.
383
+
384
+
`kubectl get po kubia-bsksp -o yaml`
385
+
386
+
#### Introducing the main parts of a POD definition
387
+
388
+
The pod definition consists of a few parts. First, there’s the Kubernetes API version used in the YAML and the type of resource the YAML is describing. Then, three important sections are found in almost all Kubernetes resources:
389
+
390
+
-**Metadata** includes the name, namespace, labels, and other information about the pod.
391
+
-**Spec** contains the actual description of the pod’s contents, such as the pod’s containers, volumes, and other data.
392
+
-**Status** contains the current information about the running pod, such as what condition the pod is in, the description and status of each container, and the pod’s internal IP and other basic info.
393
+
394
+
The status part contains read-only runtime data that shows the state of the resource at a given moment. When creating a new pod, you never need to provide the status part.
395
+
396
+
The three parts described previously show the typical structure of a Kubernetes API object. All other objects have the same anatomy. This makes understanding new objects relatively easy.
397
+
398
+
Going through all the individual properties in the previous YAML doesn’t make much sense, so, instead, let’s see what the most basic YAML for creating a pod looks like.
399
+
400
+
#### Creating a simple YAML descriptor for a pod
401
+
402
+
You’re going to create a file called kubia-manual.yaml (you can create it in any directory you want), or copy from this repo directory, where you’ll find the file inside the [PODS folder](https://github.com/knrt10/kubernetes-basicLearning/blob/master/PODS/kubia-manual.yaml). The following listing shows the entire contents of the file.
403
+
404
+
```yaml
405
+
apiVersion: v1
406
+
kind: Pod
407
+
metadata:
408
+
name: kubia-manual
409
+
spec:
410
+
containers:
411
+
- image: knrt10/kubia
412
+
name: kubia
413
+
ports:
414
+
- containerPort: 8080
415
+
protocol: TCP
416
+
```
417
+
418
+
Let’s examine this descriptor in detail. It conforms to the **v1** version of the Kubernetes API. The type of resource you’re describing is a pod, with the name **kubia-manual**. The pod consists of a single container based on the **knrt10/kubia** image. You’ve also given a name to the container and indicated that it’s listening on port **8080**.
0 commit comments