I am trying to do the prerequisites mentioned in https://hub.helm.sh/charts/jetstack/cert-manager
$ kubectl apply \
-f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.11/deploy/manifests/00-
I tried to figure out what kubectl apply
does since I joined a project with k8s already up and running and therefore having not much basic knowledge.
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply
The guide says:
Apply the configuration in pod.json
to a pod.
kubectl apply -f ./pod.json
But I don't get why in this command no target is mentioned. I expected something like:
kubectl apply -f ./pod.json application-pod-01
But nowhere is an explicit target for this apply
command of the file mentioned. I am sure I am missing a crucial concept here but can't figure it out by reading up the doc.
Most objects in the kubernetes API have a namespace and a name (if namespace is left out of the definition it defaults to the default
namespace), defined in the ObjectMetaData.
In the yaml file you will see the following:
apiVersion: v1
kind: Pod
metadata:
name: application-pod
namespace: my-namespace
The combination of name and namespace uniquily identify the object in Kubernetes, and allow kubernetes to find a specific instance of the object (e.g. pod-01
) and update it (most likely creating a new instance of the object, e.g. pod-02
).
This is the correct syntax
kubectl apply -f pod.json
OR
kubectl apply -f pod.yaml