Difference between revisions of "Kubectl apply"

From wikieduonline
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
 
<code>[[kubectl apply --help]]</code>
 
<code>[[kubectl apply --help]]</code>
 +
[[--recursive]]
  
 
* <code>[[kubectl apply -f]] https://k8s.io/examples/pods/storage/redis.yaml</code>
 
* <code>[[kubectl apply -f]] https://k8s.io/examples/pods/storage/redis.yaml</code>
Line 33: Line 34:
  
 
  kubectl apply -f ./file.yaml
 
  kubectl apply -f ./file.yaml
  Error from server (InternalError): error when creating "./file.yaml": Internal error occurred: failed calling webhook "virtualmachines- mutator.[[kubevirt.io]]": Post https://virt-api.kubevirt.svc:443/virtualmachines-mutate?timeout=30s: [[service]] "[[virt-api]]" not found
+
  Error from server (InternalError): error when creating "./file.yaml": [[Internal error occurred: failed calling webhook]] "virtualmachines- mutator.[[kubevirt.io]]": Post https://virt-api.kubevirt.svc:443/virtualmachines-mutate?timeout=30s: [[service]] "[[virt-api]]" not found
  
 
  {{is missing}}
 
  {{is missing}}
 +
 +
[[error: error parsing yourfile: error converting YAML to JSON]]: yaml: line 11:
 +
[[mapping values are not allowed in this context]]
 +
 +
error: error validating "yourfile": error validating data:
 +
 +
[ValidationError(PersistentVolumeClaim.metadata.finalizers): invalid type for
 +
[[io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta.finalizers]]: got "string", expected "array",
 +
 +
ValidationError([[PersistentVolumeClaim]]): unknown field "name" in
 +
[[io.k8s.api.core.v1.PersistentVolumeClaim]] ]; if you choose to ignore these errors, turn
 +
 +
validation off with [[--validate=false]]
 +
 +
== Warning ==
 +
Warning: resource endpoints/your-endpoint is missing the [[kubectl.kubernetes.io/last-applied-configuration]] [[annotation]] which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either [[kubectl create --save-config]] or [[kubectl apply]]. The missing annotation will be patched automatically.
 +
endpoints/your-endpoint configured
  
 
== Related ==
 
== Related ==
Line 44: Line 62:
 
* <code>[[kubectl apply --server-side]]</code>
 
* <code>[[kubectl apply --server-side]]</code>
 
* <code>[[kubectl delete]]</code>
 
* <code>[[kubectl delete]]</code>
* [[creationTimestamp]] [[metadata]]
+
* [[creationTimestamp]] [[Kubernetes metadata|metadata]]
 +
* Terraform resource: <code>[[Terraform resource: kubernetes_deployment|kubernetes_deployment]]</code>
  
 
== See also ==
 
== See also ==

Latest revision as of 10:59, 12 January 2024

kubectl apply apply a configuration to a resource by filename or stdin [1]

kubectl apply --help

--recursive
kubectl apply -f https://k8s.io/examples/application/mysql/mysql-pv.yaml
persistentvolume/mysql-pv-volume created
persistentvolumeclaim/mysql-pv-claim created

Activities[edit]

Errors[edit]

kubectl apply -f ./file.yaml
Error from server (InternalError): error when creating "./file.yaml": Internal error occurred: failed calling webhook "virtualmachines- mutator.kubevirt.io": Post https://virt-api.kubevirt.svc:443/virtualmachines-mutate?timeout=30s: service "virt-api" not found
  Warning: resource configmaps/kube-root-ca.crt is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically. secret/default-token-7z4zd created
Error from server (Conflict): error when applying patch:
.../...
to:
Resource: "/v1, Resource=configmaps", GroupVersionKind: "/v1, Kind=ConfigMap"
Name: "kube-root-ca.crt", Namespace: "your-namespace"
for: "your.yaml": Operation cannot be fulfilled on configmaps "kube-root-ca.crt": the object has been modified; please apply your changes to the latest version and try again
error: error parsing yourfile: error converting YAML to JSON: yaml: line 11: 
mapping values are not allowed in this context
error: error validating "yourfile": error validating data: 

[ValidationError(PersistentVolumeClaim.metadata.finalizers): invalid type for 
io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta.finalizers: got "string", expected "array", 

ValidationError(PersistentVolumeClaim): unknown field "name" in 
io.k8s.api.core.v1.PersistentVolumeClaim ]; if you choose to ignore these errors, turn 

validation off with --validate=false

Warning[edit]

Warning: resource endpoints/your-endpoint is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
endpoints/your-endpoint configured

Related[edit]

See also[edit]

  • https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply
  • Advertising: