From e9ec03b4e04cb29cd7a684aa28d19f38ecec6118 Mon Sep 17 00:00:00 2001 From: Bryan Kribbs Date: Wed, 24 Jul 2024 21:26:20 -0500 Subject: [PATCH] Fixing docs --- .../pods/health-checks/health-checks/index.md | 224 ------------------ docs/openshift/pods/health-checks/index.md | 4 +- .../pods/health-checks/jobs/index.md | 167 ------------- .../health-checks/multi-container/index.md | 116 --------- .../pods/health-checks/tagging/index.md | 117 --------- docs/openshift/pods/jobs/index.md | 149 ++++++------ docs/openshift/pods/multi-container/index.md | 6 +- docs/openshift/pods/tagging/index.md | 4 +- mkdocs.yml | 1 + 9 files changed, 78 insertions(+), 710 deletions(-) delete mode 100644 docs/openshift/pods/health-checks/health-checks/index.md delete mode 100644 docs/openshift/pods/health-checks/jobs/index.md delete mode 100644 docs/openshift/pods/health-checks/multi-container/index.md delete mode 100644 docs/openshift/pods/health-checks/tagging/index.md diff --git a/docs/openshift/pods/health-checks/health-checks/index.md b/docs/openshift/pods/health-checks/health-checks/index.md deleted file mode 100644 index 27d1bdf..0000000 --- a/docs/openshift/pods/health-checks/health-checks/index.md +++ /dev/null @@ -1,224 +0,0 @@ -# Liveness and Readiness Probes - -A Probe is a diagnostic performed periodically by the kubelet on a Container. To perform a diagnostic, the kubelet calls a Handler implemented by the Container. There are three types of handlers: - -***ExecAction***: Executes a specified command inside the Container. The diagnostic is considered successful if the command exits with a status code of 0. - -***TCPSocketAction***: Performs a TCP check against the Container’s IP address on a specified port. The diagnostic is considered successful if the port is open. - -***HTTPGetAction***: Performs an HTTP Get request against the Container’s IP address on a specified port and path. The diagnostic is considered successful if the response has a status code greater than or equal to 200 and less than 400. - -The kubelet can optionally perform and react to three kinds of probes on running Containers: - -***livenessProbe***: Indicates whether the Container is running. Runs for the lifetime of the Container. - -***readinessProbe***: Indicates whether the Container is ready to service requests. Only runs at start. - -### Resources - -=== "OpenShift" - [Application Health :fontawesome-solid-globe:](https://docs.openshift.com/container-platform/4.12/virt/logging_events_monitoring/virt-monitoring-vm-health.html){ .md-button } - [Virtual Machine Health :fontawesome-solid-globe:](https://docs.openshift.com/container-platform/4.12/virt/logging_events_monitoring/virt-monitoring-vm-health.html){ .md-button } - -=== "Kubernetes" - - [Container Probes](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes) - - [Configure Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) - -### References - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: my-pod -spec: - containers: - - name: app - image: busybox - command: ['sh', '-c', "echo Hello, Kubernetes! && sleep 3600"] - livenessProbe: - exec: - command: ['echo','alive'] -``` - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: my-pod -spec: - shareProcessNamespace: true - containers: - - name: app - image: bitnami/nginx - ports: - - containerPort: 8080 - livenessProbe: - tcpSocket: - port: 8080 - initialDelaySeconds: 10 - readinessProbe: - httpGet: - path: / - port: 8080 - periodSeconds: 10 -``` - -## Container Logging - -Application and systems logs can help you understand what is happening inside your cluster. The logs are particularly useful for debugging problems and monitoring cluster activity. - -Kubernetes provides no native storage solution for log data, but you can integrate many existing logging solutions into your Kubernetes cluster. - -### Resources - -**OpenShift** -- [Logs Command](https://docs.openshift.com/container-platform/4.13/cli_reference/openshift_cli/developer-cli-commands.html) -- [Cluster Logging](https://docs.openshift.com/container-platform/4.13/logging/cluster-logging.html) -- [Logging Collector](https://docs.openshift.com/container-platform/4.13/logging/config/cluster-logging-collector.html) - -**IKS** -- [Logging](https://kubernetes.io/docs/concepts/cluster-administration/logging/) - -### References - - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: counter -spec: - containers: - - name: count - image: busybox - command: ['sh','-c','i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 5; done'] -``` - - - -** Get Logs ** -``` -oc logs -``` -** Use Stern to View Logs ** -``` -brew install stern -stern . -n default -``` - - - - - -** Get Logs ** -``` -kubectl logs -``` -** Use Stern to View Logs ** -``` -brew install stern -stern . -n default -``` - - - - - -## Monitoring Applications - -To scale an application and provide a reliable service, you need to understand how the application behaves when it is deployed. You can examine application performance in a Kubernetes cluster by examining the containers, pods, services, and the characteristics of the overall cluster. Kubernetes provides detailed information about an application’s resource usage at each of these levels. This information allows you to evaluate your application’s performance and where bottlenecks can be removed to improve overall performance. - -Prometheus, a CNCF project, can natively monitor Kubernetes, nodes, and Prometheus itself. - -### Resources - -**OpenShift** -- [Monitoring Application Health](https://docs.openshift.com/container-platform/4.13/applications/application-health.html) -- [Monitoring Services](https://docs.openshift.com/container-platform/4.13/monitoring/monitoring-your-own-services.html) -- [Custom Application Metrics](https://docs.openshift.com/container-platform/4.13/monitoring/exposing-custom-application-metrics-for-autoscaling.html) - -**IKS** -- [Monitoring Resource Usage](https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/) -- [Resource Metrics](https://kubernetes.io/docs/tasks/debug-application-cluster/resource-metrics-pipeline/) - -### References - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: 500m -spec: - containers: - - name: app - image: gcr.io/kubernetes-e2e-test-images/resource-consumer:1.4 - resources: - requests: - cpu: 700m - memory: 128Mi - - name: busybox-sidecar - image: radial/busyboxplus:curl - command: [/bin/sh, -c, 'until curl localhost:8080/ConsumeCPU -d "millicores=500&durationSec=3600"; do sleep 5; done && sleep 3700'] -``` - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: 200m -spec: - containers: - - name: app - image: gcr.io/kubernetes-e2e-test-images/resource-consumer:1.4 - resources: - requests: - cpu: 300m - memory: 64Mi - - name: busybox-sidecar - image: radial/busyboxplus:curl - command: [/bin/sh, -c, 'until curl localhost:8080/ConsumeCPU -d "millicores=200&durationSec=3600"; do sleep 5; done && sleep 3700'] -``` - - - -``` - oc get projects - oc api-resources -o wide - oc api-resources -o name - - oc get nodes,ns,po,deploy,svc - - oc describe node --all - ``` - - - - - -** Verify Metrics is enabled** -``` -kubectl get --raw /apis/metrics.k8s.io/ -``` - -** Get Node Description ** -``` -kubectl describe node -``` - -** Check Resource Useage ** -``` -kubectl top pods -kubectl top nodes -``` - - - - - -## Activities - -| Task | Description | Link | -| --------------------------------| ------------------ |:----------- | -| *** Try It Yourself *** | | | -| Probes | Create some Health & Startup Probes to find what's causing an issue. | [Probes](../kube-overview/activities/labs/lab4) | diff --git a/docs/openshift/pods/health-checks/index.md b/docs/openshift/pods/health-checks/index.md index f69b3a6..b5fea93 100644 --- a/docs/openshift/pods/health-checks/index.md +++ b/docs/openshift/pods/health-checks/index.md @@ -14,7 +14,7 @@ The kubelet can optionally perform and react to three kinds of probes on running ***readinessProbe***: Indicates whether the Container is ready to service requests. Only runs at start. -### Resources +## Resources === "OpenShift" @@ -28,7 +28,7 @@ The kubelet can optionally perform and react to three kinds of probes on running [Configure Probes :fontawesome-solid-globe:](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/){ .md-button target="_blank"} -### References +## References ```yaml apiVersion: v1 diff --git a/docs/openshift/pods/health-checks/jobs/index.md b/docs/openshift/pods/health-checks/jobs/index.md deleted file mode 100644 index f0cccef..0000000 --- a/docs/openshift/pods/health-checks/jobs/index.md +++ /dev/null @@ -1,167 +0,0 @@ -# Jobs and CronJobs - -**Jobs** -A Job creates one or more Pods and ensures that a specified number of them successfully terminate. As pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will clean up the Pods it created. - - -**CronJobs** -One CronJob object is like one line of a crontab (cron table) file. It runs a job periodically on a given schedule, written in Cron format. - -All CronJob schedule: times are based on the timezone of the master where the job is initiated. - -## Resources - -**OpenShift** -- [Jobs](https://docs.openshift.com/container-platform/4.3/nodes/jobs/nodes-nodes-jobs.html) -- [CronJobs](https://docs.openshift.com/container-platform/4.3/nodes/jobs/nodes-nodes-jobs.html#nodes-nodes-jobs-creating-cron_nodes-nodes-jobs) - -**IKS** -- [Jobs to Completion](https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/) -- [Cron Jobs](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/) -- [Automated Tasks with Cron](https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/) - -## References - -It computes π to 2000 places and prints it out -```yaml -apiVersion: batch/v1 -kind: Job -metadata: - name: pi -spec: - template: - spec: - containers: - - name: pi - image: perl - command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] - restartPolicy: Never - backoffLimit: 4 -``` - -Running in parallel -```yaml -apiVersion: batch/v1 -kind: Job -metadata: - name: pi -spec: - parallelism: 2 - completions: 3 - template: - spec: - containers: - - name: pi - image: perl - command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] - restartPolicy: Never - backoffLimit: 4 -``` - -```yaml -apiVersion: batch/v1beta1 -kind: CronJob -metadata: - name: hello -spec: - schedule: "*/1 * * * *" - jobTemplate: - spec: - template: - spec: - containers: - - name: hello - image: busybox - args: - - /bin/sh - - -c - - date; echo Hello from the Kubernetes cluster - restartPolicy: OnFailure -``` - - - - -** Gets Jobs ** -``` -oc get jobs -``` -** Gets Job Description ** -``` -oc describe job pi -``` -** Gets Pods from the Job ** -``` -oc get pods -``` -** Deletes Job ** -``` -oc delete job pi -``` - -** Gets CronJob ** -``` -oc get cronjobs -``` -** Describes CronJob ** -``` -oc describe cronjobs pi -``` -** Gets Pods from CronJob ** -``` -oc get pods -``` -** Deletes CronJob ** -``` -oc delete cronjobs pi -``` - - - - - -** Gets Jobs ** -``` -kubectl get jobs -``` -** Gets Job Description ** -``` -kubectl describe job pi -``` -** Gets Pods from the Job ** -``` -kubectl get pods -``` -** Deletes Job ** -``` -kubectl delete job pi -``` - -** Gets CronJob ** -``` -kubectl get cronjobs -``` -** Describes CronJob ** -``` -kubectl describe cronjobs pi -``` -** Gets Pods from CronJob ** -``` -kubectl get pods -``` -** Deletes CronJob ** -``` -kubectl delete cronjobs pi -``` - - - - - -## Activities - -| Task | Description | Link | -| --------------------------------| ------------------ |:----------- | -| *** Try It Yourself *** | | | -| Rolling Updates Lab | Create a Rolling Update for your application. | [Rolling Updates](../kube-overview/activities/labs/lab6) | -| Cron Jobs Lab | Using Tekton to test new versions of applications. | [Crons Jobs](../kube-overview/activities/labs/lab7) | diff --git a/docs/openshift/pods/health-checks/multi-container/index.md b/docs/openshift/pods/health-checks/multi-container/index.md deleted file mode 100644 index 309caef..0000000 --- a/docs/openshift/pods/health-checks/multi-container/index.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -title: Multi-Container Pods -description: Multi-Container Pods in Kubernetes ---- - - - Multi-Containers Pod - Activities - - -# Multi-Containers Pod - -Container images solve many real-world problems with existing packaging and deployment tools, but in addition to these significant benefits, containers offer us an opportunity to fundamentally re-think the way we build distributed applications. Just as service oriented architectures (SOA) encouraged the decomposition of applications into modular, focused services, containers should encourage the further decomposition of these services into closely cooperating modular containers. By virtue of establishing a boundary, containers enable users to build their services using modular, reusable components, and this in turn leads to services that are more reliable, more scalable and faster to build than applications built from monolithic containers. - -## Resources - -**OpenShift** - -**IKS** -- [Sidecar Logging](https://kubernetes.io/docs/concepts/cluster-administration/logging/#using-a-sidecar-container-with-the-logging-agent) -- [Shared Volume Communication](https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/) -- [Toolkit Patterns](https://kubernetes.io/blog/2015/06/the-distributed-system-toolkit-patterns/) -- [Brendan Burns Paper](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/45406.pdf) - -## References - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: my-pod -spec: - volumes: - - name: shared-data - emptyDir: {} - containers: - - name: app - image: bitnami/nginx - volumeMounts: - - name: shared-data - mountPath: /app - ports: - - containerPort: 8080 - - name: sidecard - image: busybox - volumeMounts: - - name: shared-data - mountPath: /pod-data - command: ['sh', '-c', 'echo Hello from the side container > /pod-data/index.html && sleep 3600'] -``` - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: my-pod -spec: - shareProcessNamespace: true - containers: - - name: app - image: bitnami/nginx - ports: - - containerPort: 8080 - - name: sidecard - image: busybox - securityContext: - capabilities: - add: - - SYS_PTRACE - stdin: true - tty: true -``` - - - -** Attach Pods Together ** -``` -oc attach -it my-pod -c sidecard -``` -``` -ps ax -``` -``` -kill -HUP 7 -``` -``` -ps ax -``` - - - - -** Attach Pods Together ** -``` -kubectl attach -it my-pod -c sidecard -``` -``` -ps ax -``` -``` -kill -HUP 7 -``` -``` -ps ax -``` - - - - - -## Activities - -| Task | Description | Link | -| --------------------------------| ------------------ |:----------- | -| *** Try It Yourself *** | | | -| Multiple Containers | Build a container using legacy container image.| [Multiple Containers](../kube-overview/activities/labs/lab3) | diff --git a/docs/openshift/pods/health-checks/tagging/index.md b/docs/openshift/pods/health-checks/tagging/index.md deleted file mode 100644 index eef2935..0000000 --- a/docs/openshift/pods/health-checks/tagging/index.md +++ /dev/null @@ -1,117 +0,0 @@ -# Labels, Selectors, and Annotations - -Labels are key/value pairs that are attached to objects, such as pods. Labels are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system. Labels can be used to organize and to select subsets of objects. Labels can be attached to objects at creation time and subsequently added and modified at any time. Each object can have a set of key/value labels defined. Each Key must be unique for a given object. - -You can use Kubernetes annotations to attach arbitrary non-identifying metadata to objects. Clients such as tools and libraries can retrieve this metadata. - -You can use either labels or annotations to attach metadata to Kubernetes objects. Labels can be used to select objects and to find collections of objects that satisfy certain conditions. In contrast, annotations are not used to identify and select objects. The metadata in an annotation can be small or large, structured or unstructured, and can include characters not permitted by labels. - -## Resources - -**OpenShift** -- [CLI Label Commands](https://docs.openshift.com/container-platform/4.13/cli_reference/openshift_cli/developer-cli-commands.html) - -**IKS** -- [Labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) -- [Annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) - - -## References - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: my-pod - labels: - app: foo - tier: frontend - env: dev - annotations: - imageregistry: "https://hub.docker.com/" - gitrepo: "https://github.com/csantanapr/knative" -spec: - containers: - - name: app - image: bitnami/nginx -``` - - - - - -** Change Labels on Objects ** -``` -oc label pod my-pod boot=camp -``` - **Getting Pods based on their labels.** -``` -oc get pods --show-labels -``` -``` -oc get pods -L tier,env -``` -``` -oc get pods -l app -``` -``` -oc get pods -l tier=frontend -``` -``` -oc get pods -l 'env=dev,tier=frontend' -``` -``` -oc get pods -l 'env in (dev, test)' -``` -``` -oc get pods -l 'tier!=backend' -``` -``` -oc get pods -l 'env,env notin (prod)' -``` -**Delete the Pod.** -``` -oc delete pod my-pod -``` - - - - - -** Change Labels on Objects ** -``` -kubectl label pod my-pod boot=camp -``` - **Getting Pods based on their labels.** -``` -kubectl get pods --show-labels -``` -``` -kubectl get pods -L tier,env -``` -``` -kubectl get pods -l app -``` -``` -kubectl get pods -l tier=frontend -``` -``` -kubectl get pods -l 'env=dev,tier=frontend' -``` -``` -kubectl get pods -l 'env in (dev, test)' -``` -``` -kubectl get pods -l 'tier!=backend' -``` -``` -kubectl get pods -l 'env,env notin (prod)' -``` -**Delete the Pod.** -``` -kubectl delete pod my-pod -``` - - - - \ No newline at end of file diff --git a/docs/openshift/pods/jobs/index.md b/docs/openshift/pods/jobs/index.md index f0cccef..b1a65d3 100644 --- a/docs/openshift/pods/jobs/index.md +++ b/docs/openshift/pods/jobs/index.md @@ -79,89 +79,80 @@ spec: restartPolicy: OnFailure ``` - - - -** Gets Jobs ** -``` -oc get jobs -``` -** Gets Job Description ** -``` -oc describe job pi -``` -** Gets Pods from the Job ** -``` -oc get pods -``` -** Deletes Job ** -``` -oc delete job pi -``` - -** Gets CronJob ** -``` -oc get cronjobs -``` -** Describes CronJob ** -``` -oc describe cronjobs pi -``` -** Gets Pods from CronJob ** -``` -oc get pods -``` -** Deletes CronJob ** -``` -oc delete cronjobs pi -``` - - - - - -** Gets Jobs ** -``` -kubectl get jobs -``` -** Gets Job Description ** -``` -kubectl describe job pi -``` -** Gets Pods from the Job ** -``` -kubectl get pods -``` -** Deletes Job ** -``` -kubectl delete job pi -``` - -** Gets CronJob ** -``` -kubectl get cronjobs -``` -** Describes CronJob ** -``` -kubectl describe cronjobs pi -``` -** Gets Pods from CronJob ** -``` -kubectl get pods -``` -** Deletes CronJob ** -``` -kubectl delete cronjobs pi -``` - - - - +=== "OpenShift" + + **Gets Jobs** + ``` + oc get jobs + ``` + **Gets Job Description** + ``` + oc describe job pi + ``` + **Gets Pods from the Job** + ``` + oc get pods + ``` + **Deletes Job** + ``` + oc delete job pi + ``` + **Gets CronJob** + ``` + oc get cronjobs + ``` + **Describes CronJob** + ``` + oc describe cronjobs pi + ``` + **Gets Pods from CronJob** + ``` + oc get pods + ``` + **Deletes CronJob** + ``` + oc delete cronjobs pi + ``` + +=== "Kubernetes" + + **Gets Jobs** + ``` + kubectl get jobs + ``` + **Gets Job Description** + ``` + kubectl describe job pi + ``` + **Gets Pods from the Job** + ``` + kubectl get pods + ``` + **Deletes Job** + ``` + kubectl delete job pi + ``` + **Gets CronJob** + ``` + kubectl get cronjobs + ``` + **Describes CronJob** + ``` + kubectl describe cronjobs pi + ``` + **Gets Pods from CronJob** + ``` + kubectl get pods + ``` + **Deletes CronJob** + ``` + kubectl delete cronjobs pi + ``` ## Activities | Task | Description | Link | | --------------------------------| ------------------ |:----------- | -| *** Try It Yourself *** | | | +| ***Try It Yourself*** | | | | Rolling Updates Lab | Create a Rolling Update for your application. | [Rolling Updates](../kube-overview/activities/labs/lab6) | | Cron Jobs Lab | Using Tekton to test new versions of applications. | [Crons Jobs](../kube-overview/activities/labs/lab7) | diff --git a/docs/openshift/pods/multi-container/index.md b/docs/openshift/pods/multi-container/index.md index 33b5e38..9af423c 100644 --- a/docs/openshift/pods/multi-container/index.md +++ b/docs/openshift/pods/multi-container/index.md @@ -65,7 +65,7 @@ spec: === "OpenShift" - ** Attach Pods Together ** + **Attach Pods Together** ``` oc attach -it my-pod -c sidecard ``` @@ -81,7 +81,7 @@ spec: === "Kubernetes" - ** Attach Pods Together ** + **Attach Pods Together** ``` kubectl attach -it my-pod -c sidecard ``` @@ -99,5 +99,5 @@ spec: | Task | Description | Link | | --------------------------------| ------------------ |:----------- | -| *** Try It Yourself *** | | | +| ***Try It Yourself*** | | | | Multiple Containers | Build a container using legacy container image.| [Multiple Containers](../../../labs/kubernetes/lab3/index.md) | diff --git a/docs/openshift/pods/tagging/index.md b/docs/openshift/pods/tagging/index.md index c670a6f..d6ea225 100644 --- a/docs/openshift/pods/tagging/index.md +++ b/docs/openshift/pods/tagging/index.md @@ -41,7 +41,7 @@ spec: === "OpenShift" - ** Change Labels on Objects ** + **Change Labels on Objects** ``` oc label pod my-pod boot=camp ``` @@ -77,7 +77,7 @@ spec: === "Kubernetes" - ** Change Labels on Objects ** + **Change Labels on Objects** ``` kubectl label pod my-pod boot=camp ``` diff --git a/mkdocs.yml b/mkdocs.yml index 16a2421..9bea5c5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -86,6 +86,7 @@ nav: -
Deployments
: - openshift/deployments/index.md -
Rolling Updates
: openshift/deployments/updates/index.md + -
Jobs and CronJobs
: openshift/pods/jobs/index.md -
Networking
: - openshift/services-networking/index.md -
Services
: openshift/services-networking/services.md