Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update release action to auto release kustomize yaml's as assets #1371

Merged
merged 8 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
16 changes: 13 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- v5.*

permissions:
contents: write

jobs:
helm:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -35,7 +38,6 @@ jobs:
uses: fluxcd/flux2/[email protected]
- name: Clone repo
uses: actions/checkout@v4

- name: Prepare
run: |
# OCI standard enforces lower-case paths
Expand All @@ -62,6 +64,14 @@ jobs:
--path="./deploy/kustomize" \
--source="${{ github.event.repository.html_url }}" \
--revision="${GITHUB_REF_NAME}/${GITHUB_SHA}"
- name: update-kustomize-assert
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for d in deploy/kustomize/overlays/*/ ; do
kustomize build "$d" > kustomize-$(basename "$d").yaml
done
gh release upload "${{ github.ref_name }}" kustomize-*.yaml deploy/kustomize/base/crds.yaml

image:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -99,7 +109,7 @@ jobs:
- name: Build and push
run: |
declare -a arr=("quay.io/grafana-operator/grafana-operator" "ghcr.io/${{ github.repository }}" )

for i in "${arr[@]}"
do
export KO_DOCKER_REPO=${i}
Expand All @@ -111,4 +121,4 @@ jobs:
--image-label org.opencontainers.image.version=${{ github.ref_name }} \
--image-label org.opencontainers.image.created=${{ env.BUILD_DATE }}
done

55 changes: 50 additions & 5 deletions docs/docs/installation/kustomize.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ linkTitle: "Kustomize installation"
description: "How to install grafana-operator using Kustomize"
---

We are using Flux to package our Kustomize files through OCI, and they are built and released just as our helm solution.
# Flux

There is no way of downloading manifest files through the [Kustomize CLI](https://kustomize.io/), but hopefully something that will be supported in the [future](https://github.com/kubernetes-sigs/kustomize/issues/5134).
We are using Flux to package our Kustomize files through OCI, and they are built and released just as our helm solution.

So if you want to download the Kustomize manifest you need to install the [Flux cli](https://fluxcd.io/flux/installation/).

Expand All @@ -21,6 +21,10 @@ flux pull artifact oci://ghcr.io/grafana/kustomize/grafana-operator:{{<param ver

This will provide you the manifest files unpacked and ready to use.

# Kustomize / Kubectl

You can find the yaml for the `cluster_scoped` and `namespace_scoped` release on the [release page](https://github.com/grafana/grafana-operator/releases/latest)

## Install

Two overlays are provided, for namespace scoped and cluster scoped installation.
Expand All @@ -29,13 +33,13 @@ For more information look at our [documentation](https://grafana-operator.github
This will install the operator in the grafana namespace.

```shell
kubectl create -k deploy/overlays/cluster_scoped
kubectl create -f https://github.com/grafana/grafana-operator/releases/latest/download/kustomize-cluster_scoped.yaml
```

for a namespace scoped installation

```shell
kubectl create -k deploy/overlays/namespace_scoped
kubectl create -f https://github.com/grafana/grafana-operator/releases/latest/download/kustomize-namespace_scoped.yaml
```

### Patching grafana-operator
Expand All @@ -46,7 +50,48 @@ Else you will get the following error `invalid: metadata.annotations: Too long:
For example

```shell
kubectl replace -k deploy/overlays/cluster_scoped
kubectl replace -f https://github.com/grafana/grafana-operator/releases/latest/download/kustomize-namespace_scoped.yaml
```

For more information how `kubectl replace` works we recommend reading this [blog](https://blog.atomist.com/kubernetes-apply-replace-patch/).

## Kustomize

latest:

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

# this will automatically pull the latest release when `kustomize build` is executed
resources:
- https://github.com/grafana/grafana-operator/releases/latest/download/kustomize-cluster_scoped.yaml
```

pinned to release:

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

# update the version to the release you need
resources:
- https://github.com/grafana/grafana-operator/releases/download/v5.0.10/kustomize-cluster_scoped.yaml

```

### ArgoCD

If you are using ArgoCD you need to add the following patch to fix the errors during apply of the CRD.

```yaml
patches:
- patch: |-
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
argocd.argoproj.io/sync-options: Replace=true
Copy link
Collaborator

Choose a reason for hiding this comment

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

I personally use server side apply instead of replace.

metadata:
  annotations:
    argocd.argoproj.io/sync-options: ServerSideApply=true

This way the kubectl.kubernetes.io/last-applied-configuration isn't created and the CRD don't get too big.
But I guess this is individual, maybe we should provide both suggestions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I added it on my own

name: grafanas.grafana.integreatly.org
```