-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0777185
commit 4353eb6
Showing
5 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Inspecting Kubernetes Resources | ||
|
||
## Inspecting Resources with Get | ||
|
||
```shell | ||
kubectl get all | ||
kubectl create deployment my-apache --image httpd --replicas 2 | ||
kubectl get all -o wide | ||
kubectl get deploy/my-apache -o yaml | ||
``` | ||
|
||
## Inspecting Resources with Describe | ||
|
||
```shell | ||
kubectl describe deploy/my-apache | ||
kubectl describe pod/my-apache-xxxx-yyyy | ||
kubectl get nodes | ||
kubectl get node/docker-desktop -o wide | ||
kubectl describe node/docker-desktop | ||
``` | ||
|
||
## Watching Resources | ||
|
||
```shell | ||
# in first window | ||
kubectl get pods -w | ||
# in second window | ||
kubectl delete pod/my-apache-xxxx-yyyy | ||
# in first window | ||
kubectl get events | ||
kubectl get events --watch-only | ||
# in second window | ||
kubectl delete pod/my-apache-xxxx-yyyy | ||
``` | ||
|
||
## Container Logs in Kubernetes | ||
|
||
- [System Logs](https://kubernetes.io/docs/concepts/cluster-administration/system-logs/) | ||
- [Debug Running Pods](https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/) | ||
- [Logging Architecture](https://kubernetes.io/docs/concepts/cluster-administration/logging/) | ||
- [Loki - Like Prometheus, but for logs](https://github.com/grafana/loki) | ||
- [ELK Stack](https://www.elastic.co/what-is/elk-stack) | ||
|
||
```shell | ||
kubectl logs deploy/my-apache | ||
kubectl logs deploy/my-apache --follow --tail 1 | ||
kubectl logs pod/my-apache-xx-yy -c httpd | ||
kubectl logs pod/my-apache-xx-yy --all-containers=true | ||
kubectl logs -l app=my-apache | ||
# cleanup | ||
kubectl delete deployment my-apache | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Creating Pods vs. Deployments in 1.18+ | ||
|
||
**Starting in version 1.18 (released March 2020), the `kubectl run` command only does one thing: create single pods.** There were many reasons for this, but the big ones were to reduce the complexity of how the `run` command worked and to move other resource creation to the `kubectl create` command. The idea is that `kubectl run` is now similar to `docker run`. It creates a single pod, where `docker run` creates a single container. | ||
|
||
Now that everyone's finally using newer versions like 1.27+ I've replaced these videos. You can follow along on my course updates GitHub project: [bret.show/courseupdates](https://bret.show/courseupdates) | ||
|
||
Depending on which version of Kubernetes you have installed, you'll need to decide how you'll create objects. Here's a cheat sheet for how old commands should be used with the 1.18+ changes. | ||
|
||
**The bold parts are what has changed since 1.18.** | ||
|
||
## Create a single pod in 1.18+ | ||
|
||
`kubectl run nginx --image nginx` | ||
|
||
## Create a single pod with a custom command in 1.18+ | ||
|
||
`kubectl run pingpong --image alpine --command -- ping 1.1.1.1` | ||
|
||
## Create a deployment in 1.18+ | ||
|
||
`kubectl create deployment nginx --image nginx` | ||
|
||
## Create a deployment with a custom command in 1.18+ | ||
|
||
`kubectl create deployment pingpong --image alpine -- ping 1.1.1.1` | ||
|
||
Notice the double dash `--` which separates the kubectl command options from the COMMAND you want to override when starting the containers. | ||
|
||
Also notice that `run` requires the `--command -- <cmd> <arg>` while the `create deployment` just needs `-- <cmd> <arg>` at the end. | ||
|
||
For more info on the create deployment options, check out the help at `kubectl create deployment --help` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Cheat Sheets for Kubectl | ||
|
||
The kubectl CLI for Kubernetes can be more complex than Docker tools, so people have created cheat sheets. | ||
|
||
**Here are a few from the official Kubernetes docs:** | ||
|
||
[kubectl Cheat Sheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/) | ||
|
||
[kubectl for Docker Users](https://kubernetes.io/docs/reference/kubectl/docker-cli-to-kubectl/) | ||
|
||
**And this is an [entire website](https://cheatography.com/) full of cheat sheets, and you can make your own.** | ||
|
||
[Some kubectl commands and resources](https://cheatography.com/deleted-44122/cheat-sheets/kubectl/) | ||
|
||
[Kubernetes concepts](https://cheatography.com/gauravpandey44/cheat-sheets/kubernetes-k8s/) | ||
|
||
And, of course, remember the inline help with `--help`. Even just typing `kubectl` and hitting enter will show you short descriptions of all the major commands. |