Kubectl: Difference between revisions
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
=Obtaining Information about API Objects= | =Obtaining Information about API Objects= | ||
==get== | |||
kubectl get | kubectl get | ||
<tt>kubectl get</tt> and <tt>kubectl describe</tt> mask sensitive information such as a [[Kubernetes Cluster Configuration Concepts#Secret|secret]]'s content to protect it from being exposed accidentally to an onlooker or from being stored in a terminal log. | <tt>kubectl get</tt> and <tt>kubectl describe</tt> mask sensitive information such as a [[Kubernetes Cluster Configuration Concepts#Secret|secret]]'s content to protect it from being exposed accidentally to an onlooker or from being stored in a terminal log. | ||
Line 48: | Line 48: | ||
kubectl ... -o jsonpath="{.items[?(@.spec.unschedulable)].metadata.name}" | kubectl ... -o jsonpath="{.items[?(@.spec.unschedulable)].metadata.name}" | ||
==describe== | |||
kubectl describe | |||
=POSTing a Manifest= | =POSTing a Manifest= |
Revision as of 01:53, 7 September 2019
Internal
Overview
kubectl is the main Kubernetes command line tool, used to send REST API requests with JSON-formatted payloads into the API server.
Configuration
Commands
Options
Obtaining Information about API Objects
get
kubectl get
kubectl get and kubectl describe mask sensitive information such as a secret's content to protect it from being exposed accidentally to an onlooker or from being stored in a terminal log.
Output in YAML Format
kubectl get -o yaml ...
Get the Manifest for an Existing Object
The manifest can be used to recreate the object:
kubectl get pod pod-name --export -o yaml
Note that --export is deprecated and will be removed in the future so find an equivalent.
Get an Individual Attribute Only
TODO: https://gist.github.com/so0k/42313dbb3b547a0f51a547bb968696ba
kubectl ... -o jsonpath="{.status.phase}"
kubectl ... -o jsonpath="{.items[?(@.spec.unschedulable)].metadata.name}"
describe
kubectl describe
POSTing a Manifest
kubectl apply -f filename.yaml
Port Fowarding
while ! kubectl -n my-namespace port-forward service/my-service 8787:8787; do sleep 1; done