Merge pull request #612 from pwittrock/book

kubectl book - add `newName` function
This commit is contained in:
Kubernetes Prow Robot 2019-03-14 16:52:57 -07:00 committed by GitHub
commit 77950cb93d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 124 additions and 94 deletions

View File

@ -27,7 +27,7 @@ List the contexts in the kubeconfig file
{% sample lang="yaml" %} {% sample lang="yaml" %}
```sh ```sh
$ kubectl config get-contexts deploykubectl config get-contexts
``` ```
```sh ```sh
@ -47,7 +47,7 @@ Print information about the current context
{% sample lang="yaml" %} {% sample lang="yaml" %}
```sh ```sh
$ kubectl config --kubeconfig=config-demo view --minify deploykubectl config --kubeconfig=config-demo view --minify
``` ```
```yaml ```yaml
@ -87,7 +87,7 @@ the name of the context.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```sh ```sh
$ export CLUSTER=us-west2-c; kubectl apply -k ${CLUSTER} --context=${CLUSTER} deployexport CLUSTER=us-west2-c; kubectl apply -k ${CLUSTER} --context=${CLUSTER}
``` ```
{% endmethod %} {% endmethod %}
@ -105,9 +105,9 @@ the name of the context.
```sh ```sh
# change the context to us-west2-c # change the context to us-west2-c
$ kubectl config use-context us-west2-c deploykubectl config use-context us-west2-c
# deploy Resources from the ./us-west2-c/kustomization.yaml # deploy Resources from the ./us-west2-c/kustomization.yaml
$ kubectl apply -k ./us-west2-c deploykubectl apply -k ./us-west2-c
``` ```
{% endmethod %} {% endmethod %}
@ -125,7 +125,7 @@ the name of the directory containing the kubeconfig.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```sh ```sh
$ kubectl apply -k ./us-west2-c --kubeconfig /path/to/us-west2-c/config deploykubectl apply -k ./us-west2-c --kubeconfig /path/to/us-west2-c/config
``` ```
{% endmethod %} {% endmethod %}

View File

@ -17,7 +17,7 @@ made by Apply.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```sh ```sh
$ kubectl diff -k ./dir/ deploykubectl diff -k ./dir/
``` ```
{% endmethod %} {% endmethod %}
@ -33,7 +33,7 @@ By default, the "diff" command available in your path will be run with "-u" (uni
{% sample lang="yaml" %} {% sample lang="yaml" %}
```sh ```sh
$ export KUBECTL_EXTERNAL_DIFF=meld; kubectl diff -k ./dir/ deployexport KUBECTL_EXTERNAL_DIFF=meld; kubectl diff -k ./dir/
``` ```
{% endmethod %} {% endmethod %}

View File

@ -83,7 +83,7 @@ Techniques:
**Base Branch:** **Base Branch:**
```bash ```bash
$ tree deploytree
. .
├── bases ├── bases
│   ├── ... │   ├── ...
@ -113,7 +113,7 @@ $ tree
**Deploy Branches:** **Deploy Branches:**
```bash ```bash
$ tree deploytree
. .
├── bases # From Base Branch ├── bases # From Base Branch
│   ├── ... │   ├── ...
@ -129,7 +129,7 @@ $ tree
``` ```
```bash ```bash
$ tree deploytree
. .
├── bases # From Base Branch ├── bases # From Base Branch
│   ├── ... │   ├── ...
@ -141,7 +141,7 @@ $ tree
``` ```
```bash ```bash
$ tree deploytree
. .
├── bases # From Base Branch ├── bases # From Base Branch
│   ├── ... │   ├── ...
@ -196,7 +196,7 @@ Techniques:
**Base Branch:** **Base Branch:**
```bash ```bash
$ tree deploytree
. .
├── bases ├── bases
│   ├── ... │   ├── ...
@ -226,7 +226,7 @@ $ tree
**Deploy Branches:** **Deploy Branches:**
```bash ```bash
$ tree deploytree
. .
└── deploy-prod └── deploy-prod
   ├── us-central    ├── us-central
@ -238,7 +238,7 @@ $ tree
``` ```
```bash ```bash
$ tree deploytree
. .
└── deploy-staging └── deploy-staging
└── us-west └── us-west
@ -246,7 +246,7 @@ $ tree
``` ```
```bash ```bash
$ tree deploytree
. .
└── deploy-test └── deploy-test
└── us-west └── us-west

View File

@ -72,7 +72,7 @@ Techniques:
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ tree deploytree
. .
├── bases # Used as a Base only ├── bases # Used as a Base only
│   ├── kustomization.yaml │   ├── kustomization.yaml

View File

@ -77,7 +77,7 @@ Techniques:
**Base Repository:** **Base Repository:**
```bash ```bash
$ tree deploytree
. .
├── bases # Used as a Base only ├── bases # Used as a Base only
│   ├── kustomization.yaml │   ├── kustomization.yaml
@ -124,7 +124,7 @@ $ tree
```bash ```bash
# sre team # sre team
$ tree deploytree
. .
├── prod ├── prod
│   ├── us-central │   ├── us-central
@ -137,7 +137,7 @@ $ tree
```bash ```bash
# qa team # qa team
$ tree deploytree
. .
├── staging # Staging ├── staging # Staging
│   └── us-west │   └── us-west
@ -146,7 +146,7 @@ $ tree
```bash ```bash
# dev team # dev team
$ tree deploytree
. .
└── test # Test └── test # Test
└── us-west └── us-west

View File

@ -1,5 +1,5 @@
{% panel style="info", title="TL;DR" %} {% panel style="info", title="TL;DR" %}
- Override Base Pod and PodTemplate Image Tags - Override Base Pod and PodTemplate Image **Names** and **Tags**
- Override Base Pod and PodTemplate Environment Variables and Arguments - Override Base Pod and PodTemplate Environment Variables and Arguments
{% endpanel %} {% endpanel %}
@ -21,9 +21,14 @@ Common examples include:
{% method %} {% method %}
**Use Case:** Different Environments (test, dev, staging, canary, prod) use images with different tags. **Use Case:** Different Environments (test, dev, staging, canary, prod) use images with different tags.
Override the tag for an `image` field from a [Pod Template](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/#pod-templates) Override the name or tag for an `image` field from a [Pod Template](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/#pod-templates)
in a base by specifying the `images` field in the `kustomization.yaml`. The `newTag` may in a base by specifying the `images` field in the `kustomization.yaml`.
be specified to override the image tag for images whose image name matches `name`.
| Field | Description | Example Field | Example Result |
|-----------|--------------------------------------------------------------------------|----------| --- |
| `name` | Match images with this image name| `name: nginx`| |
| `newTag` | Override the image **tag** or **digest** for images whose image name matches `name` | `newTag: new` | `nginx:old` -> `nginx:new` |
| `newName` | Override the image **name** for images whose image name matches `name` | `newImage: nginx-special` | `nginx:old` -> `nginx-special:old` |
{% sample lang="yaml" %} {% sample lang="yaml" %}
**Input:** The `kustomization.yaml` file **Input:** The `kustomization.yaml` file
@ -35,6 +40,7 @@ bases:
images: images:
- name: nginx-pod - name: nginx-pod
newTag: 1.15 newTag: 1.15
newName: nginx-pod-2
``` ```
**Base:** Resources to be modified by the `kustomization.yaml` **Base:** Resources to be modified by the `kustomization.yaml`
@ -89,7 +95,7 @@ spec:
containers: containers:
# The image image tag has been changed for the container # The image image tag has been changed for the container
- name: nginx - name: nginx
image: nginx-pod:1.15 image: nginx-pod-2:1.15
``` ```
{% endmethod %} {% endmethod %}

View File

@ -72,10 +72,10 @@ ResourceConfig files using `-f`.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
# Apply the Resource Config # Apply the Resource Config
$ kubectl apply -k . deploykubectl apply -k .
# View the Resources # View the Resources
$ kubectl get -k . deploykubectl get -k .
``` ```
{% endmethod %} {% endmethod %}

View File

@ -1,5 +1,5 @@
{% panel style="info", title="TL;DR" %} {% panel style="info", title="TL;DR" %}
- Override or set the Tag for Container Images - Override or set the Name and Tag for Container Images
{% endpanel %} {% endpanel %}
# Container Images # Container Images
@ -9,7 +9,7 @@
It may be useful to define the tags of container images which are It may be useful to define the tags of container images which are
used across many Workloads. used across many Workloads.
- Update the container image tag for multiple Workloads at once - Update the container image name or tag for multiple Workloads at once
- Increase visibility of the versions of container images being used within - Increase visibility of the versions of container images being used within
the project the project
- Set the image tag from external sources - such as environment variables - Set the image tag from external sources - such as environment variables
@ -25,13 +25,21 @@ the `kustomization.yaml` using the `images` field. When `images` are
specified, Apply will override the images whose image name matches `name` with a new specified, Apply will override the images whose image name matches `name` with a new
tag. tag.
| Field | Description | Example Field | Example Result |
|-----------|--------------------------------------------------------------------------|----------| --- |
| `name` | Match images with this image name| `name: nginx`| |
| `newTag` | Override the image **tag** or **digest** for images whose image name matches `name` | `newTag: new` | `nginx:old` -> `nginx:new` |
| `newName` | Override the image **name** for images whose image name matches `name` | `newImage: nginx-special` | `nginx:old` -> `nginx-special:old` |
{% method %} {% method %}
**Example:** Use `images` in the `kustomization.yaml` to update the container **Example:** Use `images` in the `kustomization.yaml` to update the container
images in `deployment.yaml` images in `deployment.yaml`
Apply will set the `nginx` image to have the tag `1.8.0` - e.g. `nginx:1.8.0`. Apply will set the `nginx` image to have the tag `1.8.0` - e.g. `nginx:1.8.0` and
This will set the tag for *all* images matching the *name*. change the image name to `nginx-special`.
This will set the name and tag for *all* images matching the *name*.
{% sample lang="yaml" %} {% sample lang="yaml" %}
**Input:** The kustomization.yaml and deployment.yaml files **Input:** The kustomization.yaml and deployment.yaml files
@ -43,6 +51,7 @@ kind: Kustomization
images: images:
- name: nginx # match images with this name - name: nginx # match images with this name
newTag: 1.8.0 # override the tag newTag: 1.8.0 # override the tag
newName: nginx-special # override the name
resources: resources:
- deployment.yaml - deployment.yaml
``` ```
@ -88,13 +97,28 @@ spec:
app: nginx app: nginx
spec: spec:
containers: containers:
# The image has been changed to include the tag # The image has been changed
- image: nginx:1.8.0 - image: nginx-special:1.8.0
name: nginx name: nginx
``` ```
{% endmethod %} {% endmethod %}
## Setting a Name
{% method %}
The name for an image may be set by specifying `newName` and the name of the old container image.
{% sample lang="yaml" %}
```yaml
# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: mycontainerregistry/myimage
newName: differentregistry/myimage
```
{% endmethod %}
## Setting a Tag ## Setting a Tag
{% method %} {% method %}
@ -141,8 +165,8 @@ download the [kustomize standalone](https://github.com/kubernetes-sigs/kustomize
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kustomize edit set imagetag foo:$(git log -n 1 --pretty=format:"%H") deploykustomize edit set imagetag foo:$(git log -n 1 --pretty=format:"%H")
$ kubectl apply -f . deploykubectl apply -f .
``` ```
{% endmethod %} {% endmethod %}
@ -155,8 +179,8 @@ It is also possible to set a Tag from an environment variable using the same tec
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kustomize edit set image foo:$FOO_IMAGE_TAG deploykustomize edit set image foo:$FOO_IMAGE_TAG
$ kubectl apply -f . deploykubectl apply -f .
``` ```
{% endmethod %} {% endmethod %}

View File

@ -15,7 +15,7 @@ Print the logs for a Pod running a single Container
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl logs echo-c6bc8ccff-nnj52 deploykubectl logs echo-c6bc8ccff-nnj52
``` ```
```bash ```bash
@ -42,7 +42,7 @@ Print the logs for all Pods for a Workload
```bash ```bash
# Print logs from all containers matching label # Print logs from all containers matching label
$ kubectl logs -l app=nginx deploykubectl logs -l app=nginx
``` ```
{% endmethod %} {% endmethod %}
@ -65,7 +65,7 @@ Stream logs from a container.
```bash ```bash
# Follow logs from container # Follow logs from container
$ kubectl logs nginx-78f5d695bd-czm8z -f deploykubectl logs nginx-78f5d695bd-czm8z -f
``` ```
{% endmethod %} {% endmethod %}
@ -81,7 +81,7 @@ crashed or are crash looping.
```bash ```bash
# Print logs from exited container # Print logs from exited container
$ kubectl logs nginx-78f5d695bd-czm8z -p deploykubectl logs nginx-78f5d695bd-czm8z -p
``` ```
{% endmethod %} {% endmethod %}
@ -97,7 +97,7 @@ containers.
```bash ```bash
# Print logs from the nginx container in the nginx-78f5d695bd-czm8z Pod # Print logs from the nginx container in the nginx-78f5d695bd-czm8z Pod
$ kubectl logs nginx-78f5d695bd-czm8z -c nginx deploykubectl logs nginx-78f5d695bd-czm8z -c nginx
``` ```
{% endmethod %} {% endmethod %}
@ -112,7 +112,7 @@ Print the logs that occurred after an absolute time.
```bash ```bash
# Print logs since a date # Print logs since a date
$ kubectl logs nginx-78f5d695bd-czm8z --since-time=2018-11-01T15:00:00Z deploykubectl logs nginx-78f5d695bd-czm8z --since-time=2018-11-01T15:00:00Z
``` ```
{% endmethod %} {% endmethod %}
@ -134,7 +134,7 @@ Examples:
```bash ```bash
# Print logs for the past hour # Print logs for the past hour
$ kubectl logs nginx-78f5d695bd-czm8z --since=1h deploykubectl logs nginx-78f5d695bd-czm8z --since=1h
``` ```
{% endmethod %} {% endmethod %}
@ -150,7 +150,7 @@ Include timestamps in the log lines
```bash ```bash
# Print logs with timestamps # Print logs with timestamps
$ kubectl logs -l app=echo --timestamps deploykubectl logs -l app=echo --timestamps
``` ```
```bash ```bash

View File

@ -24,7 +24,7 @@ Copy a local file to a remote Pod in a cluster.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir deploykubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir
``` ```
{% endmethod %} {% endmethod %}
@ -40,7 +40,7 @@ Copy a remote file from a Pod to a local file.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl cp /tmp/foo <some-pod>:/tmp/bar deploykubectl cp /tmp/foo <some-pod>:/tmp/bar
``` ```
{% endmethod %} {% endmethod %}
@ -55,7 +55,7 @@ Specify the Container within a Pod running multiple containers.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container> deploykubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>
``` ```
{% endmethod %} {% endmethod %}
@ -70,7 +70,7 @@ Set the Pod namespace by prefixing the Pod name with `<namespace>/` .
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar deploykubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar
``` ```
{% endmethod %} {% endmethod %}

View File

@ -35,7 +35,7 @@ To get a Shell in a Container, use the `-t -i` options to get a tty and attach S
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl exec -t -i nginx-78f5d695bd-czm8z bash deploykubectl exec -t -i nginx-78f5d695bd-czm8z bash
``` ```
```bash ```bash

View File

@ -15,7 +15,7 @@ Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 60
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl port-forward pod/mypod 5000 6000 deploykubectl port-forward pod/mypod 5000 6000
``` ```
{% endmethod %} {% endmethod %}
@ -30,7 +30,7 @@ deployment
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl port-forward deployment/mydeployment 5000 6000 deploykubectl port-forward deployment/mydeployment 5000 6000
``` ```
{% endmethod %} {% endmethod %}
@ -44,7 +44,7 @@ Listen on port 8888 locally, forwarding to 5000 in the pod
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl port-forward pod/mypod 8888:5000 deploykubectl port-forward pod/mypod 8888:5000
``` ```
{% endmethod %} {% endmethod %}
@ -58,7 +58,7 @@ Listen on a random port locally, forwarding to 5000 in the pod
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl port-forward pod/mypod :5000 deploykubectl port-forward pod/mypod :5000
``` ```
{% endmethod %} {% endmethod %}
@ -74,7 +74,7 @@ Specify the Container within a Pod running multiple containers.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container> deploykubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>
``` ```
{% endmethod %} {% endmethod %}
@ -90,7 +90,7 @@ Set the Pod namespace by prefixing the Pod name with `<namespace>/` .
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar deploykubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar
``` ```
{% endmethod %} {% endmethod %}

View File

@ -28,13 +28,13 @@ To visit the nginx service go to the Proxy URL at
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl proxy deploykubectl proxy
Starting to serve on 127.0.0.1:8001 Starting to serve on 127.0.0.1:8001
``` ```
```bash ```bash
$ curl http://127.0.0.1:8001/api/v1/namespaces/default/services/nginx/proxy/ deploycurl http://127.0.0.1:8001/api/v1/namespaces/default/services/nginx/proxy/
``` ```
{% endmethod %} {% endmethod %}
@ -56,7 +56,7 @@ A common usecase is to connect to Services running as part of the cluster itself
Services and their Proxy Urls with `kubectl cluster-info`. Services and their Proxy Urls with `kubectl cluster-info`.
```bash ```bash
$ kubectl cluster-info deploykubectl cluster-info
Kubernetes master is running at https://104.197.5.247 Kubernetes master is running at https://104.197.5.247
GLBCDefaultBackend is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/default-http-backend:http/proxy GLBCDefaultBackend is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/default-http-backend:http/proxy

View File

@ -24,7 +24,7 @@ source.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl version deploykubectl version
``` ```
```bash ```bash
@ -49,7 +49,7 @@ add-ons.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl cluster-info deploykubectl cluster-info
``` ```
```bash ```bash
@ -78,7 +78,7 @@ top nodes and pods.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl top node deploykubectl top node
``` ```
```bash ```bash
@ -104,7 +104,7 @@ Print the Resource Types available in the cluster.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl api-resources deploykubectl api-resources
``` ```
```bash ```bash
@ -127,7 +127,7 @@ Print the API versions available in the cluster.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl api-versions deploykubectl api-versions
``` ```
```bash ```bash
@ -159,7 +159,7 @@ Resource types. This is useful for learning about the type.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl explain deployment --api-version apps/v1 deploykubectl explain deployment --api-version apps/v1
``` ```
```bash ```bash

View File

@ -19,7 +19,7 @@ Resources, and formats and prints this information on multiple lines.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl describe deployments deploykubectl describe deployments
``` ```
```bash ```bash

View File

@ -68,7 +68,7 @@ Print the JSON representation of the first Deployment in the list on a single li
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment.v1.apps -o=jsonpath='{.items[0]}{"\n"}' deploykubectl get deployment.v1.apps -o=jsonpath='{.items[0]}{"\n"}'
``` ```
@ -86,7 +86,7 @@ Print the `metadata.name` field for the first Deployment in the list.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment.v1.apps -o=jsonpath='{.items[0].metadata.name}{"\n"}' deploykubectl get deployment.v1.apps -o=jsonpath='{.items[0].metadata.name}{"\n"}'
``` ```
```bash ```bash
@ -104,7 +104,7 @@ For each Deployment, print its `metadata.name` field and a newline afterward.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment.v1.apps -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' deploykubectl get deployment.v1.apps -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'
``` ```
```bash ```bash
@ -123,7 +123,7 @@ For each Deployment, print its `metadata.name` and `.status.availableReplicas`.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment.v1.apps -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.availableReplicas}{"\n"}{end}' deploykubectl get deployment.v1.apps -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.availableReplicas}{"\n"}{end}'
``` ```
```bash ```bash
nginx 1 nginx 1
@ -141,7 +141,7 @@ Print the list of Deployments as single line.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment.v1.apps -o=jsonpath='{@}{"\n"}' deploykubectl get deployment.v1.apps -o=jsonpath='{@}{"\n"}'
``` ```
```bash ```bash
@ -159,7 +159,7 @@ Print each Deployment on a new line.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment.v1.apps -o=jsonpath='{range .items[*]}{@}{"\n"}{end}' deploykubectl get deployment.v1.apps -o=jsonpath='{range .items[*]}{@}{"\n"}{end}'
``` ```
```bash ```bash

View File

@ -15,7 +15,7 @@ Get all Resources provided by the `kustomization.yaml` in project/.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get -k project/ deploykubectl get -k project/
``` ```
{% endmethod %} {% endmethod %}
@ -27,7 +27,7 @@ Get all Resources present in the Resource Config for a directory.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get -f configs/ deploykubectl get -f configs/
``` ```
{% endmethod %} {% endmethod %}
@ -44,17 +44,17 @@ The Singular, Plural, Short Name also apply to *Types with Name* and *Types with
```bash ```bash
# Plural # Plural
$ kubectl get deployments deploykubectl get deployments
``` ```
```bash ```bash
# Singular # Singular
$ kubectl get deployment deploykubectl get deployment
``` ```
```bash ```bash
# Short name # Short name
$ kubectl get deploy deploykubectl get deploy
``` ```
{% endmethod %} {% endmethod %}
@ -69,11 +69,11 @@ The Group and Version for the Resource are explicit.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments.apps deploykubectl get deployments.apps
``` ```
```bash ```bash
$ kubectl get deployments.v1.apps deploykubectl get deployments.v1.apps
``` ```
{% endmethod %} {% endmethod %}
@ -86,7 +86,7 @@ Get named Resources in a namespace for a given type.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment nginx deploykubectl get deployment nginx
``` ```
{% endmethod %} {% endmethod %}
@ -98,7 +98,7 @@ Get **all** Resources in a namespace **matching a label select** for a given typ
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments -l app=nginx deploykubectl get deployments -l app=nginx
``` ```
{% endmethod %} {% endmethod %}
@ -114,7 +114,7 @@ The `---all-namespaces` flag will **fetch Resources from all namespaces**.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments --all-namespaces deploykubectl get deployments --all-namespaces
``` ```
{% endmethod %} {% endmethod %}
@ -128,7 +128,7 @@ Get and Describe can accept **multiple Resource types**, and it will print them
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments,services deploykubectl get deployments,services
``` ```
{% endmethod %} {% endmethod %}
@ -142,7 +142,7 @@ Get and Describe can accept **multiple Resource types and names**.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get kubectl get rc/web service/frontend pods/web-pod-13je7 deploykubectl get kubectl get rc/web service/frontend pods/web-pod-13je7
``` ```
{% endmethod %} {% endmethod %}
@ -156,7 +156,7 @@ These Resources can be view with the `--include-uninitialized` flag.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments --include-uninitialized deploykubectl get deployments --include-uninitialized
``` ```
{% endmethod %} {% endmethod %}
@ -170,7 +170,7 @@ The `--ignore-not-found` flag will cause kubectl to exit 0 if the Resource is no
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment nginx --ignore-not-found deploykubectl get deployment nginx --ignore-not-found
``` ```
{% endmethod %} {% endmethod %}

View File

@ -32,7 +32,7 @@ Print the Raw Resource formatting it as YAML.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments -o yaml deploykubectl get deployments -o yaml
``` ```
```yaml ```yaml
@ -120,7 +120,7 @@ Print the Raw Resource formatting it as JSON.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments -o json deploykubectl get deployments -o json
``` ```
```json ```json

View File

@ -29,7 +29,7 @@ be a summary of fields.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments nginx deploykubectl get deployments nginx
``` ```
```bash ```bash
@ -52,7 +52,7 @@ be a summary of fields.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get -o=wide deployments nginx deploykubectl get -o=wide deployments nginx
``` ```
```bash ```bash
@ -74,7 +74,7 @@ Print out specific fields as Columns.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments -o custom-columns="Name:metadata.name,Replicas:spec.replicas,Strategy:spec.strategy.type" deploykubectl get deployments -o custom-columns="Name:metadata.name,Replicas:spec.replicas,Strategy:spec.strategy.type"
``` ```
```bash ```bash
@ -112,7 +112,7 @@ Print out all labels on each Resource in a single column (last).
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployment --show-labels deploykubectl get deployment --show-labels
``` ```
```bash ```bash
@ -135,7 +135,7 @@ they want to know which API is being used.
{% sample lang="yaml" %} {% sample lang="yaml" %}
```bash ```bash
$ kubectl get deployments --show-kind deploykubectl get deployments --show-kind
``` ```
```bash ```bash