kubectl apply --server-side

1 개요[ | ]

kubectl apply --server-side

2 실습 1[ | ]

$ echo '{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"cm1"},"data":{"HOST":"foo.com","PORT":"8080"}}' | kubectl apply -f -
configmap/cm1 created
$ kubectl patch configmap cm1 -p '{"data":{"PORT":"9090"}}'
configmap/cm1 patched
$ echo '{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"cm1"},"data":{"HOST":"bar.com","PORT":"8080"}}' | kubectl apply -f -
configmap/cm1 configured

3 실습 2[ | ]

$ echo '{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"cm2"},"data":{"HOST":"foo.com","PORT":"8080"}}' | kubectl apply -f -
configmap/cm2 created
$ kubectl patch configmap cm2 -p '{"data":{"PORT":"9090"}}'
configmap/cm2 patched
$ echo '{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"cm2"},"data":{"HOST":"bar.com","PORT":"8080"}}' | kubectl apply --server-side -f -
error: Apply failed with 1 conflict: conflict with "kubectl-patch" using v1: .data.PORT
Please review the fields above--they currently have other managers. Here
are the ways you can resolve this warning:
* If you intend to manage all of these fields, please re-run the apply
  command with the `--force-conflicts` flag.
* If you do not intend to manage all of the fields, please edit your
  manifest to remove references to the fields that should keep their
  current managers.
* You may co-own fields by updating your manifest to match the existing
  value; in this case, you'll become the manager if the other manager(s)
  stop managing the field (remove it from their configuration).
See https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts

4 실습 3[ | ]

$ echo '{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"cm3"},"data":{"HOST":"foo.com","PORT":"8080"}}' | kubectl apply --server-side -f -
configmap/cm3 serverside-applied
$ kubectl patch configmap cm3 -p '{"data":{"PORT":"9090"}}'
configmap/cm3 patched
$ echo '{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"cm3"},"data":{"HOST":"bar.com","PORT":"8080"}}' | kubectl apply -f -
Warning: resource configmaps/cm3 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.
configmap/cm3 configured

5 실습 4[ | ]

$ echo '{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"cm4"},"data":{"HOST":"foo.com","PORT":"8080"}}' | kubectl apply --server-side -f -
configmap/cm4 serverside-applied
$ kubectl patch configmap cm4 -p '{"data":{"PORT":"9090"}}'
configmap/cm4 patched
$ echo '{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"cm4"},"data":{"HOST":"bar.com","PORT":"8080"}}' | kubectl apply --server-side -f -
error: Apply failed with 1 conflict: conflict with "kubectl-patch" using v1: .data.PORT
Please review the fields above--they currently have other managers. Here
are the ways you can resolve this warning:
* If you intend to manage all of these fields, please re-run the apply
  command with the `--force-conflicts` flag.
* If you do not intend to manage all of the fields, please edit your
  manifest to remove references to the fields that should keep their
  current managers.
* You may co-own fields by updating your manifest to match the existing
  value; in this case, you'll become the manager if the other manager(s)
  stop managing the field (remove it from their configuration).
See https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts

6 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}