### Install Hello Populator Example Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2022/volume-populators-beta.md Deploy the example 'hello' populator, which introduces a custom resource definition for creating pre-populated volumes. ```shell kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/lib-volume-populator/v1.0.1/example/hello-populator/crd.yaml kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/lib-volume-populator/87a47467b86052819e9ad13d15036d65b9a32fbb/example/hello-populator/deploy.yaml ``` -------------------------------- ### Install Example Hello Populator Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2021/volume-populators-alpha.md Deploy the example 'hello' populator, which creates a custom resource definition and its associated controller for demonstration purposes. ```terminal kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/lib-volume-populator/master/example/hello-populator/crd.yaml kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/lib-volume-populator/master/example/hello-populator/deploy.yaml ``` -------------------------------- ### Example Output: Pod Details Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/run-application/run-replicated-stateful-application.md This shows an example of the output when getting pod details, highlighting the node name where the pod is scheduled. ```shell NAME READY STATUS RESTARTS AGE IP NODE mysql-2 2/2 Running 0 15m 10.244.5.27 kubernetes-node-9l2t ``` -------------------------------- ### Clone Repository and Create Kubernetes Namespace Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2018/developing-on-kubernetes.md Initial setup commands to clone the example repository and create a dedicated Kubernetes namespace for the application. ```bash $ git clone https://github.com/kubernauts/dok-example-us.git && cd dok-example-us $ kubectl create namespace dok ``` -------------------------------- ### Create a Namespace for Examples Source: https://github.com/kubernetes/website/blob/main/content/en/docs/reference/access-authn-authz/service-accounts-admin.md Use this command to create the 'examplens' namespace, which is required to follow the steps in this guide. ```shell kubectl create namespace examplens ``` -------------------------------- ### Example Output for `kubectl get pods --output=wide` Source: https://github.com/kubernetes/website/blob/main/content/en/docs/contribute/style/style-guide.md This is an example of the output returned by the `kubectl get pods --output=wide` command. ```console NAME READY STATUS RESTARTS AGE IP NODE nginx 1/1 Running 0 13s 10.200.0.4 worker0 ``` -------------------------------- ### Example `kubectl get pods` Output Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/extend-kubernetes/socks5-proxy-access-api.md This is an example of the output received when running `kubectl get pods` through the configured SOCKS5 proxy. It shows the status of pods in the `kube-system` namespace. ```console NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-85cb69466-klwq8 1/1 Running 0 5m46s ``` -------------------------------- ### Gloo Gateway Installation Confirmation Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2020/two-phased-canary-rollout-with-gloo.md Confirms the successful installation of the Gloo gateway, indicating the creation of the `gloo-system` namespace and the start of the installation process. ```text Creating namespace gloo-system... Done. Starting Gloo installation... Gloo was successfully installed! ``` -------------------------------- ### Full client-go clientcmd Example for Kubernetes Interaction Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2026/clientcmd-tutorial.md This example demonstrates loading Kubernetes configuration, creating a client, determining the active namespace, and listing nodes. It handles configuration overrides and command-line flags. ```go package main import ( "context" "fmt" "os" "github.com/spf13/pflag" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" ) func main() { // Loading rules, no configuration loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() // Overrides and flag (command line argument) setup configOverrides := &clientcmd.ConfigOverrides{} flags := pflag.NewFlagSet("clientcmddemo", pflag.ExitOnError) clientcmd.BindOverrideFlags(configOverrides, flags, clientcmd.RecommendedConfigOverrideFlags("")) flags.StringVarP(&loadingRules.ExplicitPath, "kubeconfig", "", "", "absolute path(s) to the kubeconfig file(s)") flags.Parse(os.Args) // Client construction kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides) config, err := kubeConfig.ClientConfig() if err != nil { if clientcmd.IsEmptyConfig(err) { panic("Please provide a configuration pointing to the Kubernetes API server") } panic(err) } client, err := kubernetes.NewForConfig(config) if err != nil { panic(err) } // How to find out what namespace to use namespace, overridden, err := kubeConfig.Namespace() if err != nil { panic(err) } fmt.Printf("Chosen namespace: %s; overridden: %t\n", namespace, overridden) // Let's use the client nodeList, err := client.CoreV1().Nodes().List(context.TODO(), v1.ListOptions{}) if err != nil { panic(err) } for _, node := range nodeList.Items { fmt.Println(node.Name) } } ``` -------------------------------- ### Install Jinja2 for Python Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/job/parallel-processing-expansion.md Install the Jinja2 template library for Python, which is required for the advanced templating example. ```shell pip install --user jinja2 ``` -------------------------------- ### Configure Startup, Liveness, and Readiness Probes Source: https://github.com/kubernetes/website/blob/main/content/en/docs/concepts/workloads/pods/probes.md This example demonstrates how to configure startup, liveness, and readiness probes for a container using httpGet checks, along with various timing and threshold parameters. ```yaml apiVersion: v1 kind: Pod metadata: name: probe-example spec: containers: - name: app image: registry.k8s.io/e2e-test-images/agnhost:2.40 ports: - containerPort: 8080 startupProbe: httpGet: path: /healthz port: 8080 failureThreshold: 30 periodSeconds: 10 livenessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 10 periodSeconds: 5 timeoutSeconds: 3 failureThreshold: 3 readinessProbe: httpGet: path: /ready port: 8080 periodSeconds: 5 ``` -------------------------------- ### Install and Run a kubectl Plugin Source: https://github.com/kubernetes/website/blob/main/content/en/docs/reference/kubectl/_index.md This example demonstrates the steps to make a kubectl plugin executable, move it into the system's PATH, and then execute it to identify the current user. ```shell # make the file executable sudo chmod +x ./kubectl-whoami # and move it into your PATH sudo mv ./kubectl-whoami /usr/local/bin kubectl whoami Current user: plugins-user ``` -------------------------------- ### Install conntrack package Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2020/wsl2-dockerdesktop-k8s.md Install the `conntrack` package to resolve the 'conntrack' error encountered when starting Minikube. ```bash # Install the conntrack package sudo apt install -y conntrack ``` -------------------------------- ### Configure kubelet using a YAML file Source: https://github.com/kubernetes/website/blob/main/content/en/docs/reference/setup-tools/kubeadm/generated/kubeadm_init/kubeadm_init_phase_kubelet-start.md Demonstrates how to use `kubeadm init phase kubelet-start` with a configuration file to apply kubelet settings. ```bash # Writes a dynamic environment file with kubelet flags from a InitConfiguration file. kubeadm init phase kubelet-start --config config.yaml ``` -------------------------------- ### Run test_examples.sh Examples Source: https://github.com/kubernetes/website/blob/main/scripts/README.md Executes the example files bundled with the website to test for changes. ```bash $ ./scripts/test_examples.sh run ``` -------------------------------- ### Install Kompose by Building from Source Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/configure-pod-container/translate-compose-kubernetes.md Installs Kompose by pulling the latest development changes from the master branch using `go get`. ```sh go get -u github.com/kubernetes/kompose ``` -------------------------------- ### Install test_examples.sh Dependencies Source: https://github.com/kubernetes/website/blob/main/scripts/README.md Installs the necessary dependencies required for the `test_examples.sh` script to function. ```bash $ ./scripts/test_examples.sh install ``` -------------------------------- ### Example Output: Kubeadm Token Create Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/administer-cluster/kubeadm/adding-linux-nodes.md This shows an example of the new token generated by the `kubeadm token create` command. ```console 5didvk.d09sbcov8ph2amjw ``` -------------------------------- ### Example CSR Status Output Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/tls/managing-tls-in-a-cluster.md This shows an example output of `kubectl get csr` after a certificate has been approved and issued, indicating its signer and condition. ```none NAME AGE SIGNERNAME REQUESTOR REQUESTEDDURATION CONDITION my-svc.my-namespace 20m example.com/serving yourname@example.com Approved,Issued ``` -------------------------------- ### Create CronJob with Specific Examples Source: https://github.com/kubernetes/website/blob/main/content/en/docs/reference/kubectl/generated/kubectl_create/kubectl_create_cronjob.md Examples demonstrating how to create a cron job, including one with a specified command. ```bash # Create a cron job kubectl create cronjob my-job --image=busybox --schedule="*/1 * * * *" ``` ```bash # Create a cron job with a command kubectl create cronjob my-job --image=busybox --schedule="*/1 * * * *" -- date ``` -------------------------------- ### Full kubeadm init Configuration Example (v1beta4) Source: https://github.com/kubernetes/website/blob/main/content/en/docs/reference/config-api/kubeadm-config.v1beta4.md This YAML file demonstrates a complete `kubeadm init` configuration, combining `InitConfiguration` with bootstrap tokens, node registration details, taints, kubelet extra arguments, preflight error ignores, and image pull policies. ```yaml apiVersion: kubeadm.k8s.io/v1beta4 kind: InitConfiguration bootstrapTokens: - token: "9a08jv.c0izixklcxtmnze7" description: "kubeadm bootstrap token" ttl: "24h" - token: "783bde.3f89s0fje9f38fhf" description: "another bootstrap token" usages: - authentication - signing groups: - system:bootstrappers:kubeadm:default-node-token nodeRegistration: name: "ec2-10-100-0-1" criSocket: "unix:///var/run/containerd/containerd.sock" taints: - key: "kubeadmNode" value: "someValue" effect: "NoSchedule" kubeletExtraArgs: - name: v value: "5" ignorePreflightErrors: - IsPrivilegedUser imagePullPolicy: "IfNotPresent" imagePullSerial: true ``` -------------------------------- ### Install csi-sanity with go get Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2020/csi-driver-testing.md Use this command to install the latest csi-sanity binary from the master branch. The compiled binary will be located in $GOPATH/bin/csi-sanity. ```shell go get github.com/kubernetes-csi/csi-test/cmd/csi-sanity ``` -------------------------------- ### Retry Minikube start with sudo Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2020/wsl2-dockerdesktop-k8s.md Attempt to start Minikube again after installing `conntrack`, first as a regular user, then with `sudo` to address permission issues. ```bash # Create a minikube one node cluster minikube start --driver=none # We got a permissions error > try again with sudo sudo minikube start --driver=none ``` -------------------------------- ### Create a Pod with initial resource requests Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/configure-pod-container/resize-container-resources.md Creates a Pod named `resize-demo` in the `qos-example` namespace using the `pod-resize.yaml` manifest. ```shell kubectl create -f pod-resize.yaml -n qos-example ``` -------------------------------- ### Example: Prepare machine for control plane Source: https://github.com/kubernetes/website/blob/main/content/en/docs/reference/setup-tools/kubeadm/generated/kubeadm_join/kubeadm_join_phase_control-plane-prepare.md Demonstrates how to use `kubeadm join phase control-plane-prepare` to prepare a machine for serving as a control plane node. ```bash # Prepares the machine for serving a control plane kubeadm join phase control-plane-prepare all ``` -------------------------------- ### Install dependencies and run Python application locally Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2019/get-started-with-kubernetes-using-python.md Install required Python packages using pip and then start the Flask development server. ```bash pip install -r requirements.txt python main.py ``` -------------------------------- ### Install Kuberhealthy (No Prometheus) Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2020/k8s-kpis-with-kuberhealthy.md Installs Kuberhealthy via Helm without any Prometheus integration, suitable for setups using its JSON status page or InfluxDB. ```bash helm install kuberhealthy kuberhealthy/kuberhealthy ``` -------------------------------- ### Download Example Seccomp Profiles Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tutorials/security/seccomp.md Use these shell commands to create a directory and download the example seccomp profiles for use in the tutorial. ```shell mkdir ./profiles curl -L -o profiles/audit.json https://k8s.io/examples/pods/security/seccomp/profiles/audit.json curl -L -o profiles/violation.json https://k8s.io/examples/pods/security/seccomp/profiles/violation.json curl -L -o profiles/fine-grained.json https://k8s.io/examples/pods/security/seccomp/profiles/fine-grained.json ls profiles ``` -------------------------------- ### Kubelet User ID Range Example Source: https://github.com/kubernetes/website/blob/main/content/en/docs/concepts/workloads/pods/user-namespaces.md This snippet shows an example of a user ID range configuration for kubelet, indicating the starting ID and the total number of IDs available. ```text kubelet:65536:7208960 ``` -------------------------------- ### Create a Hello World Deployment Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/extend-kubernetes/http-proxy-access-api.md Use this command to deploy a sample 'hello-app' if no application is already running in the cluster. ```shell kubectl create deployment hello-app --image=gcr.io/google-samples/hello-app:2.0 --port=8080 ``` -------------------------------- ### Check Docker and Kubectl Installation Status Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2020/wsl2-dockerdesktop-k8s.md Verify if the Docker CLI and daemon, as well as the `kubectl` command, are installed and accessible within the WSL2 environment before proceeding with Kubernetes setup. ```bash # Try to see if the docker cli and daemon are installed docker version # Same for kubectl kubectl version ``` -------------------------------- ### Example Pod Status Output (Init:1/2) Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/debug/debug-application/debug-init-containers.md An example of `kubectl get pod` output showing an Init Container status of `Init:1/2`, indicating one of two Init Containers has completed. ```shell NAME READY STATUS RESTARTS AGE 0/1 Init:1/2 0 7s ``` -------------------------------- ### Retrieve Docker Compose Example File Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2017/kompose-helps-developers-move-docker.md Use this command to download the example `docker-compose.yaml` file from the Kompose GitHub repository, which will be used for subsequent conversion demonstrations. ```bash $ wget https://raw.githubusercontent.com/kubernetes/kompose/master/examples/docker-compose.yaml ``` -------------------------------- ### Install and Configure NFS on CentOS 7 Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2017/postgresql-clusters-kubernetes-statefulsets.md These commands install NFS utilities, enable and start NFS services, create a shared directory, and configure its permissions for use as Persistent Volumes. ```bash sudo setsebool -P virt\_use\_nfs 1 sudo yum -y install nfs-utils libnfsidmap sudo systemctl enable rpcbind nfs-server sudo systemctl start rpcbind nfs-server rpc-statd nfs-idmapd sudo mkdir /nfsfileshare sudo chmod 777 /nfsfileshare/ sudo vi /etc/exports sudo exportfs -r ``` -------------------------------- ### Initialize Minikube Environment and Clone Repository Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2018/developing-on-kubernetes.md Prepares the local development environment by cloning the example repository, configuring Docker to use Minikube's daemon, and creating a Kubernetes namespace. ```bash $ git clone https://github.com/kubernauts/dok-example-us.git && cd dok-example-us $ eval $(minikube docker-env) $ kubectl create namespace dok ``` -------------------------------- ### Listing kubectl Plugins Source: https://github.com/kubernetes/website/blob/main/content/en/docs/reference/kubectl/generated/kubectl_plugin/_index.md Provides examples for listing all installed kubectl plugins and for displaying only their binary names. ```bash # List all available plugins kubectl plugin list ``` ```bash # List only binary names of available plugins without paths kubectl plugin list --name-only ``` -------------------------------- ### Examples of kubectl explain Command Usage Source: https://github.com/kubernetes/website/blob/main/content/en/docs/reference/kubectl/generated/kubectl_explain/_index.md Demonstrates various ways to use `kubectl explain` to get documentation for resources, their fields, and different API versions or output formats. ```bash # Get the documentation of the resource and its fields kubectl explain pods ``` ```bash # Get all the fields in the resource kubectl explain pods --recursive ``` ```bash # Get the explanation for deployment in supported api versions kubectl explain deployments --api-version=apps/v1 ``` ```bash # Get the documentation of a specific field of a resource kubectl explain pods.spec.containers ``` ```bash # Get the documentation of resources in different format kubectl explain deployment --output=plaintext-openapiv2 ``` -------------------------------- ### Example Output: Pod Creation Confirmation Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2024/cri-o-seccomp-oci-artifacts.md Confirms that the pod has been successfully created after applying the updated configuration. ```console pod/pod created ``` -------------------------------- ### Check Operator SDK Version Source: https://github.com/kubernetes/website/blob/main/content/en/blog/_posts/2021/writing-a-controller-for-pod-labels.md Verify the installed version of the Operator SDK before starting controller development. ```terminal $ operator-sdk version operator-sdk version: "v1.4.2", commit: "4b083393be65589358b3e0416573df04f4ae8d9b", kubernetes version: "v1.19.4", go version: "go1.15.8", GOOS: "darwin", GOARCH: "amd64" ``` -------------------------------- ### Expose Deployment as NodePort Service Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/access-application-cluster/service-access-application-cluster.md Exposes the 'hello-world' Deployment as a NodePort Service named 'example-service'. ```shell kubectl expose deployment hello-world --type=NodePort --name=example-service ``` -------------------------------- ### Get Status of Fine-Grained Pod Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tutorials/security/seccomp.md Check the status of the 'fine-pod' to confirm it has started successfully with the fine-grained seccomp profile. ```shell kubectl get pod fine-pod ``` -------------------------------- ### Deploy Hello World Application with kubectl Source: https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/access-application-cluster/service-access-application-cluster.md Creates a Deployment and an associated ReplicaSet, each running the Hello World application. ```shell kubectl apply -f https://k8s.io/examples/service/access/hello-application.yaml ```