Skip to content

Commit

Permalink
new references and lectures
Browse files Browse the repository at this point in the history
  • Loading branch information
BretFisher committed Jun 26, 2023
1 parent 0777185 commit 4353eb6
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 2 deletions.
2 changes: 0 additions & 2 deletions references/S01 Quick Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
- [Docker Official Images](https://docs.docker.com/docker-hub/official_images/)
- [Apache Official Image (httpd)](https://hub.docker.com/_/httpd)

### Shell Commands

```shell
docker version
docker run -d -p 8800:80 httpd
Expand Down
9 changes: 9 additions & 0 deletions references/S15 Your First Pods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

> Shell commands and reference links, per lecture
## Kubectl run, create, and apply

- [Kubectl Reference](https://kubernetes.io/docs/reference/kubectl/)

## Our First Pod With Kubectl run

- [Kubectl Cheat Sheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)
Expand All @@ -17,6 +21,9 @@ kubectl get all

## Your First Deployment with kubectl create

- [kubectl create deployment](https://kubernetes.io/docs/tutorials/kubernetes-basics/deploy-app/deploy-intro/)
- [Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)

```shell
kubectl create deployment my-nginx --image nginx
kubectl get pods
Expand All @@ -27,6 +34,8 @@ kubectl delete deployment my-nginx

## Scaling ReplicaSets

- [ReplicaSets](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/)

```shell
kubectl create deployment my-apache --image httpd
kubectl get all
Expand Down
52 changes: 52 additions & 0 deletions references/S16 Inspecting Kubernetes Resources.md
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
```
31 changes: 31 additions & 0 deletions written-lectures/1.18-changes-to-kubectl-run.md
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`
17 changes: 17 additions & 0 deletions written-lectures/cheat-sheets-for-kubectl.md
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.

0 comments on commit 4353eb6

Please sign in to comment.