Skip to content

Commit

Permalink
Merge pull request #431 from Danil-Grigorev/update-plugin-instruction…
Browse files Browse the repository at this point in the history
…s-and-release-script

🌱 Update plugin instructions and release script
  • Loading branch information
k8s-ci-robot committed Feb 26, 2024
2 parents 3e0130f + d309c96 commit b1f52e3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ upload-staging-artifacts: ## Upload release artifacts to the staging bucket
update-helm-plugin-repo:
./hack/update-plugin-yaml.sh $(RELEASE_TAG)
./hack/update-helm-repo.sh $(RELEASE_TAG)
./hack/publish-index-changes.sh $(RELEASE_TAG)

.PHONY: promote-images
promote-images: $(KPROMO)
Expand Down
29 changes: 24 additions & 5 deletions docs/book/src/02_installation/01_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,38 @@ The `cluster-api-operator` plugin can be installed using krew, the kubectl plugi

1. Add the cluster-api-operator plugin index to krew:
```bash
clusterctl krew index add operator https://github.com/kubernetes-sigs/cluster-api-operator.git
kubectl krew index add operator https://github.com/kubernetes-sigs/cluster-api-operator.git
```

2. Install the cluster-api-operator plugin:
```bash
clusterctl krew install operator/operator
kubectl krew install operator/clusterctl-operator
```

3. Verify the installation:
```bash
clusterctl operator
kubectl operator
```

This should print help information for the clusterctl operator plugin.
This should print help information for the kubectl operator plugin.

The `cluster-api-operator` plugin is now installed and ready to use with both `kubectl` and `clusterctl`.
The `cluster-api-operator` plugin is now installed and ready to use with `kubectl`.

### Optionally: installing as a `clusterctl` plugin
Typically the plugin is installed under `~/.krew/bin/kubectl-operator`, which would be present under your `$PATH` after correct `krew` installation. If you want to use plugin with `clusterctl`, you need to rename this file to be prefixed with `clusterctl-` instead, like so:
```bash
cp ~/.krew/bin/kubectl-operator ~/.krew/bin/clusterctl-operator
```

After that plugin is available to use as a `clusterctl` plugin:
```bash
clusterctl operator --help
```

## Upgrade

To upgrade your plugin with the new release of `cluster-api-operator` you will need to run:

```bash
kubectl krew upgrade
```
36 changes: 36 additions & 0 deletions hack/publish-index-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

if [ $# -ne 1 ]; then
echo "Usage: $0 RELEASE_TAG"
exit 1
fi

RELEASE_TAG="$1"
BRANCH_NAME="index-${RELEASE_TAG}"
COMMIT_MESSAGE="This PR updates index.yaml for ${RELEASE_TAG}. Automatically generated by make update-helm-repo."
PR_TITLE="🌱 Update helm chart index.yaml to ${RELEASE_TAG}"
PR_DESCRIPTION="**What this PR does / why we need it:**\n\nThis PR updates index.yaml for ${RELEASE_TAG}. Automatically generated by \`make update-helm-repo\`."

# Checkout index-${RELEASE_TAG} branch
git checkout -b "${BRANCH_NAME}"

# Add files to commit
git add plugins/clusterctl-operator.yaml index.yaml

# Commit changes with appropriate message
git commit -m "${COMMIT_MESSAGE}"

# Push changes to origin
git push origin "${BRANCH_NAME}"

if ! command -v gh &> /dev/null
then
echo "GitHub CLI (gh) is not installed."
echo "Please open a pull request with the following details:"
echo "Title: $PR_TITLE"
echo -e "Description: \n$PR_DESCRIPTION"
exit 0
fi

# Open a PR with title and description
gh pr create --title "${PR_TITLE}" --body "${PR_DESCRIPTION}"

0 comments on commit b1f52e3

Please sign in to comment.