Skip to content

Commit

Permalink
Stop components with manuall override (#57)
Browse files Browse the repository at this point in the history
* Stop components with manuall override

* remove references to goreleaser and update readme, enable cross compilation in Dockerfile
  • Loading branch information
Richard87 authored Sep 13, 2024
1 parent e616622 commit 695cfbe
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58.2
version: v1.60.3
working-directory: './radix-cluster-cleanup'
39 changes: 0 additions & 39 deletions .goreleaser.yml

This file was deleted.

12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM docker.io/golang:1.22.5-alpine3.20 AS builder
FROM --platform=$BUILDPLATFORM docker.io/golang:1.22.5-alpine3.20 AS builder

ARG TARGETARCH
ENV CGO_ENABLED=0 \
GOOS=linux
GOOS=linux \
GOARCH=${TARGETARCH}

WORKDIR /src

Expand All @@ -13,15 +15,13 @@ RUN go mod download
COPY ./radix-cluster-cleanup .
RUN go build -ldflags="-s -w" -o /build/radix-cluster-cleanup

COPY ./run_cluster_cleanup.sh .

#Get busybox shell for distroless
FROM gcr.io/distroless/base:debug AS debug
# Final stage, ref https://github.com/GoogleContainerTools/distroless/blob/main/base/README.md for distroless
FROM gcr.io/distroless/static
WORKDIR /app
COPY ./run_cluster_cleanup.sh .
COPY --from=builder /build/radix-cluster-cleanup .
COPY --from=builder /src/run_cluster_cleanup.sh .
COPY --from=debug /busybox/sh /bin
USER 1000
ENTRYPOINT ["/app/run_cluster_cleanup.sh"]
ENTRYPOINT ["/app/run_cluster_cleanup.sh"]
9 changes: 0 additions & 9 deletions Dockerfile.goreleaser

This file was deleted.

30 changes: 2 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,8 @@ LOG_LEVEL=DEBUG ./rx-cleanup --help

### Building and releasing

We are making releases available as GitHub releases using [go-releaser](https://goreleaser.com/). The release process is controlled by the `.goreleaser.yml` file.

To make a release:
1. Set the version number in the constant `version` in the file `cmd/version.go`
2. Ensure there is no `dist` folder in the project (left from previous release)
3. Get the [Personal Access Token](https://github.com/settings/tokens) (PAT) - with access to repository and `write:packages` scope, and with enabled SSO for organisation (or create it)
4. Login to the docker repository with your PAT
```
echo $CR_PAT | docker login ghcr.io -u magnus-longva-bouvet --password-stdin
```
5. Run the command to create a version with a tag, build a docker image and push them to GitHub repository. Recommended to set <number_of_cores> to a number well below your CPU count if you want to get any work done while compiling.
```
git tag -a v<version_numnber> -m "<release_note>"
git push origin v<version_number>
goreleaser release --rm-dist --parallelism <number_of_cores>
```
6. If something goes wrong:
- open the GitHub repository and delete [created tag](https://github.com/equinor/radix-cluster-cleanup/releases/) (with release)
- delete it locally ` git tag -d v0.0.1`
- reset changes `git reset --hard`
- delete the `dist` folder
- perform the previous step `make release ...` again
To generate a local version for debugging purposes, it can be built using:
```
CGO_ENABLED=0 GOOS=darwin go build -ldflags "-s -w" -a -installsuffix cgo -o ./rx-cleanup
```
Deployment is managed by Flux, that monitors `master` and `release` branches.
Any commits here will trigger a pull requets in radix-flux to release the commit to their respective cluster

### Contributing

Expand Down
4 changes: 2 additions & 2 deletions radix-cluster-cleanup/cmd/stopRrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"time"

"github.com/equinor/radix-cluster-cleanup/pkg/settings"
"github.com/equinor/radix-common/utils/pointers"
"github.com/equinor/radix-operator/pkg/apis/kube"
v1 "github.com/equinor/radix-operator/pkg/apis/radix/v1"
"github.com/equinor/radix-operator/pkg/apis/utils/numbers"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -95,7 +95,7 @@ func stopRr(kubeClient *kube.Kube, rr v1.RadixRegistration) error {
func scaleRdComponentsToZeroReplicas(kubeClient *kube.Kube, rd v1.RadixDeployment) error {
componentNames := make([]string, 0)
for i := range rd.Spec.Components {
rd.Spec.Components[i].Replicas = numbers.IntPtr(0)
rd.Spec.Components[i].ReplicasOverride = pointers.Ptr(0)
componentNames = append(componentNames, rd.Spec.Components[i].Name)
}
_, err := kubeClient.RadixClient().RadixV1().RadixDeployments(rd.Namespace).Update(context.TODO(), &rd, metav1.UpdateOptions{})
Expand Down
75 changes: 39 additions & 36 deletions radix-cluster-cleanup/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ go 1.22.0
toolchain go1.22.5

require (
github.com/equinor/radix-common v1.9.3
github.com/equinor/radix-operator v1.57.1
github.com/equinor/radix-common v1.9.4
github.com/equinor/radix-operator v1.58.3
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.8.1
k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
)

require (
dario.cat/mergo v1.0.0 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cert-manager/cert-manager v1.14.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
github.com/evanphx/json-patch v5.8.1+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/expr-lang/expr v1.15.8 // indirect
github.com/expr-lang/expr v1.16.9 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.7 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
Expand All @@ -40,44 +40,47 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kedacore/keda/v2 v2.13.1 // indirect
github.com/kedacore/keda/v2 v2.15.1 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.70.0 // indirect
github.com/prometheus-operator/prometheus-operator/pkg/client v0.70.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.76.0 // indirect
github.com/prometheus-operator/prometheus-operator/pkg/client v0.76.0 // indirect
github.com/prometheus/client_golang v1.20.2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.53.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.6.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.30.2 // indirect
k8s.io/apiextensions-apiserver v0.30.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect
knative.dev/pkg v0.0.0-20240116073220-b488e7be5902 // indirect
sigs.k8s.io/controller-runtime v0.18.2 // indirect
k8s.io/api v0.31.0 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240808142205-8e686545bdb8 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
knative.dev/pkg v0.0.0-20240805063731-c88d5dad9653 // indirect
sigs.k8s.io/controller-runtime v0.19.0 // indirect
sigs.k8s.io/gateway-api v1.0.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/secrets-store-csi-driver v1.4.0 // indirect
sigs.k8s.io/secrets-store-csi-driver v1.4.5 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 695cfbe

Please sign in to comment.