Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/installation/install-binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ Execute operations at `karmada-01`.
git clone https://github.com/karmada-io/karmada
cd karmada/charts/karmada/_crds/bases

kubectl apply -f .
kubectl apply -Rf .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The -R (--recursive) flag for kubectl apply is deprecated and will be removed in a future version. The recommended way to apply resources from a directory and its subdirectories is to use kustomize.

Using kubectl apply -k . is the modern and more robust approach, assuming a kustomization.yaml file exists in the karmada/charts/karmada/_crds/bases directory. Given the directory is named bases, it's likely intended for use with kustomize. If a kustomization.yaml is not present, one should be added to make these instructions future-proof.

Suggested change
kubectl apply -Rf .
kubectl apply -k .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -R (--recursive) flag for kubectl apply is deprecated and will be removed in a future version.

@gemini-code-assist Where did you get this information? When I run kubectl apply --help, I don't see any deprecation notice.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that kubectl apply --help doesn't explicitly mark -R as deprecated. My apologies for the strong wording on "deprecated and will be removed".

However, the core point remains: for applying resources from a directory, especially one named bases (which is a common convention for Kustomize bases), using kubectl apply -k . is the recommended and more robust approach in the Kubernetes ecosystem.

Here's why:

  1. Redundancy of -R: Since Kubernetes v1.14, kubectl apply -f <directory> is recursive by default. This means explicitly adding -R is often unnecessary and doesn't add new functionality in many common scenarios.
  2. Kustomize as Best Practice: For managing and customizing Kubernetes configurations in a directory structure, Kustomize (kubectl apply -k) is the standard tool. It provides powerful features for overlaying configurations, managing patches, and handling dependencies, which simple recursive kubectl apply -f or kubectl apply -Rf cannot.
  3. Future-Proofing: While -R might not be officially deprecated in the help text, relying on kustomize aligns with current best practices and ensures the installation instructions are more resilient to future changes in kubectl's behavior regarding directory application.

Given that the directory is karmada/charts/karmada/_crds/bases, it strongly suggests an intention for Kustomize usage to manage these CRDs. If a kustomization.yaml file is present (or intended to be present), kubectl apply -k . is the correct command. If not, adding one would be a good practice for managing these CRDs.

Therefore, while the term "deprecated" might be technically debatable in the context of kubectl --help output, the recommendation to use kubectl apply -k . is based on current Kubernetes best practices for managing configurations in a structured way, especially for CRDs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using kubectl apply -k is indeed a more recommended approach, especially since we already have a kustomization.yaml defined. However, simply replacing kubectl apply -f . with kubectl apply -k . in place won't work—we need to initialize the CRD files beforehand.

@tianser3, could you help test whether the following commands work?

git clone https://github.com/karmada-io/karmada
cd karmada/charts/karmada/_crds/patches

ca_string=$(cat /etc/karmada/pki/server-ca.crt | base64 | tr "\n" " "|sed s/[[:space:]]//g)
sed -i "s/{{caBundle}}/${ca_string}/g" webhook_in_resourcebindings.yaml
sed -i "s/{{caBundle}}/${ca_string}/g"  webhook_in_clusterresourcebindings.yaml
# You need to change 172.31.209.245:4443 to your Load Balancer host:port.
sed -i 's/karmada-webhook.karmada-system.svc:443/172.31.209.245:4443/g' webhook_in_resourcebindings.yaml
sed -i 's/karmada-webhook.karmada-system.svc:443/172.31.209.245:4443/g' webhook_in_clusterresourcebindings.yaml

cd ../
kubectl apply -k .
cd ../../../..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered a new issue: the contents of webhook_in_resourcebindings.yaml and webhook_in_clusterresourcebindings.yaml have changed, rendering the original sed command no longer applicable. If we update the aforementioned command to:

git clone https://github.com/karmada-io/karmada
cd karmada/charts/karmada/_crds

ca_string=$(cat /etc/karmada/pki/server-ca.crt | base64 | tr "\n" " "|sed s/[[:space:]]//g)
sed -i "s/{{caBundle}}/${ca_string}/g" patches/webhook_in_resourcebindings.yaml
sed -i "s/{{caBundle}}/${ca_string}/g"  patches/webhook_in_clusterresourcebindings.yaml
# You need to change 172.31.209.245:4443 to your Load Balancer host:port.
sed -i 's/{{name}}\.{{namespace}}\.svc:443/172.31.209.245:4443/g' patches/webhook_in_resourcebindings.yaml
sed -i 's/{{name}}\.{{namespace}}\.svc:443/172.31.209.245:4443/g' patches/webhook_in_clusterresourcebindings.yaml

kubectl apply -k .
cd -

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That work well.
please close it. @zhzhuang-zju

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tianser3, you mean resolve the comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly ping @tianser3


cd ../patches/
ca_string=$(cat /etc/karmada/pki/server-ca.crt | base64 | tr "\n" " "|sed s/[[:space:]]//g)
Expand Down