Difference between revisions of "Kubectl apply"
Jump to navigation
Jump to search
↑ https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply
(→Errors) |
|||
(62 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | {{lowercase}} |
+ | <code>[[kubectl]] apply</code> apply a configuration to a [[resource]] by filename or <code>[[stdin]]</code> <ref>https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply</ref> | ||
+ | <code>[[kubectl apply --help]]</code> | ||
+ | [[--recursive]] | ||
− | * <code>[[kubectl apply]] | + | * <code>[[kubectl apply -f]] https://k8s.io/examples/pods/storage/redis.yaml</code> |
+ | * <code>[[kubectl apply -f myredis.yaml]]</code> | ||
+ | |||
+ | * <code>[[kubectl apply -f ./secret.yaml]]</code> | ||
+ | |||
+ | * <code>[[kubectl apply -f]] your.yaml [[-n]] your-[[Kubernetes namespaces|namespace]]</code> | ||
+ | |||
+ | * <code>[[kubectl apply -k]]</code> | ||
+ | |||
+ | * <code> kubectl apply --dry-run=server</code> | ||
+ | * <code>[[kubectl apply --server-side]]</code> | ||
+ | |||
+ | * [[Dashboard]]: <code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml</code> | ||
+ | * [[Istio install]]: <code>[[kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml]]</code> | ||
+ | |||
+ | kubectl apply -f https://k8s.io/examples/application/mysql/mysql-pv.yaml | ||
+ | persistentvolume/mysql-pv-volume created | ||
+ | persistentvolumeclaim/mysql-pv-claim created | ||
== Activities == | == Activities == | ||
− | * [[ | + | * [[CKA v1.15]], [[CKA v1.21]]: [[Create and configure a basic Pod]] (<code>[[kubectl apply]]</code>) |
+ | |||
+ | == Errors == | ||
+ | * <code>[[Cannot unmarshal XXXXX into Go struct field]]</code> | ||
+ | * <code>[[Operation cannot be fulfilled on]] ...</code> | ||
+ | * <code>[[the object has been modified; please apply your changes to the latest version and try again]]</code> | ||
+ | |||
+ | 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 | ||
+ | |||
+ | {{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 == | ||
+ | * <code>[[kubectl create]]</code> | ||
+ | * <code>[[kubectl edit]]</code> | ||
+ | * <code>[[kubectl run]]</code> | ||
+ | * <code>[[kubectl get]]</code> | ||
+ | * <code>[[kubectl apply --server-side]]</code> | ||
+ | * <code>[[kubectl delete]]</code> | ||
+ | * [[creationTimestamp]] [[Kubernetes metadata|metadata]] | ||
+ | * Terraform resource: <code>[[Terraform resource: kubernetes_deployment|kubernetes_deployment]]</code> | ||
== See also == | == See also == | ||
− | * {{kubectl}} | + | * {{kubectl apply}} |
− | |||
− | |||
[[Category:Kubernetes]] | [[Category:Kubernetes]] |
Latest revision as of 10:59, 12 January 2024
kubectl apply
apply a configuration to a resource by filename or stdin
[1]
--recursive
kubectl apply -f your.yaml -n your-namespace
kubectl apply --dry-run=server
kubectl apply --server-side
- Dashboard:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml
- Istio install:
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f https://k8s.io/examples/application/mysql/mysql-pv.yaml persistentvolume/mysql-pv-volume created persistentvolumeclaim/mysql-pv-claim created
Contents
Activities[edit]
Errors[edit]
Cannot unmarshal XXXXX into Go struct field
Operation cannot be fulfilled on ...
the object has been modified; please apply your changes to the latest version and try again
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]
kubectl create
kubectl edit
kubectl run
kubectl get
kubectl apply --server-side
kubectl delete
- creationTimestamp metadata
- Terraform resource:
kubernetes_deployment
See also[edit]
kubectl apply, --server-side, -k, -f, creationTimestamp, kubectl.kubernetes.io/last-applied-configuration, --validate=false
Advertising: