Skip to content

Commit

Permalink
Merge branch 'main' into bump_systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Jul 11, 2022
2 parents 5ac8aa1 + e80aeec commit 6a45f0b
Show file tree
Hide file tree
Showing 50 changed files with 516 additions and 551 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
go-version: 1.17.x
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-build-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-build-go-
${{ runner.os }}-build-go-${{ hashFiles('**/go.sum') }}
- name: Build
run: make build
4 changes: 2 additions & 2 deletions .github/workflows/chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Build chart for release
if: startsWith(github.ref, 'refs/tags/')
run: |
REPO=quay.io/costoolkit/rancheros-operator TAG=${GITHUB_REF##*/} make chart
REPO=quay.io/costoolkit/elemental-operator TAG=${GITHUB_REF##*/} make chart
- name: Publish chart to release
uses: fnkr/github-action-ghr@v1
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -41,7 +41,7 @@ jobs:
git config --global user.name "${{ github.actor }}"
git checkout gh-pages
rm index.yaml
helm repo index --url https://rancher-sandbox.github.io/rancheros-operator .
helm repo index --url https://rancher.github.io/elemental-operator .
git add index.yaml build/ -f
git commit -m "Updating helm repo to main commit ${{ github.sha }}"
git push --set-upstream origin gh-pages
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Export tag
id: export_tag
run: |
git describe --abbrev=0 --tags
TAG=`git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0"`
echo "::set-output name=operator_tag::$TAG"
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
quay.io/costoolkit/rancheros-operator
quay.io/costoolkit/elemental-operator
tags: |
type=semver,pattern={{raw}}
- name: Set up Docker Buildx
Expand All @@ -37,4 +43,6 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
target: ros-operator
push: true
push: true
build-args: |
VERSION=${{ steps.export_tag.outputs.operator_tag }}
26 changes: 17 additions & 9 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
id: export_tag
run: |
TAG=`git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0"`
echo "::set-output name=ros_tag::$TAG"
echo "::set-output name=operator_tag::$TAG"
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
quay.io/costoolkit/rancheros-operator-ci
quay.io/costoolkit/elemental-operator-ci
tags: |
type=sha,format=short,prefix=${{ steps.export_tag.outputs.ros_tag }}-
type=sha,format=short,prefix=${{ steps.export_tag.outputs.operator_tag }}-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -48,12 +48,14 @@ jobs:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION=${{ steps.export_tag.outputs.operator_tag }}
- name: Make chart
run: make chart
- name: Set chart output
id: chart
run: |
CHART=$(basename `find . -type f -name "rancheros-operator*.tgz" -print`)
CHART=$(basename `find . -type f -name "elemental-operator*.tgz" -print`)
echo "::set-output name=chart_name::$CHART"
- name: Upload chart
uses: actions/upload-artifact@v2
Expand All @@ -67,9 +69,8 @@ jobs:
runs-on: ubuntu-latest
needs: push-docker
env:
ROS_CHART: ${{ github.workspace }}/build/${{ needs.push-docker.outputs.chart_name }}
CHART: ${{ github.workspace }}/build/${{ needs.push-docker.outputs.chart_name }}
KUBE_VERSION: ${{ matrix.kubernetes }}
BRIDGE_IP: "172.17.0.1"
steps:
- uses: actions/checkout@v2
- name: Download chart
Expand All @@ -80,11 +81,18 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '^1.17'
go-version: 1.17.x
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-test-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-test-go-${{ hashFiles('**/go.sum') }}
- name: Deps
run: |
ip a
make test_deps
make unit-tests-deps
- uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.11.1"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gorelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17.x
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-release-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-release-go-
${{ runner.os }}-release-go-${{ hashFiles('**/go.sum') }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
go-version: 1.17.x
- name: Analysis
uses: golangci/golangci-lint-action@v3
with:
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/test.yaml

This file was deleted.

13 changes: 12 additions & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Unit tests
on:
pull_request:
push:
branches:
- main
concurrency:
group: tests-${{ github.head_ref || github.ref }}-${{ github.repository }}
cancel-in-progress: true
Expand All @@ -12,7 +15,15 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '^1.16'
go-version: 1.17.x
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-test-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-test-go-${{ hashFiles('**/go.sum') }}
- name: Get dependencies
run: |
# Needed for github.com/google/go-tspi/tspi
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
run:
timeout: 5m
skip-dirs:
skip-files:
- "zz_generated_*"
tests: false
output:
Expand Down
5 changes: 3 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
project_name: rancheros-operator
project_name: elemental-operator
builds:
- main: ./cmd/operator
env:
- CGO_ENABLED=0
ldflags:
- -extldflags -static -s
- -extldflags -static -w -s
- -X github.com/rancher/elemental-operator/version.Version={{.Tag}}
goos:
- linux
goarch:
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.17-alpine as build
ENV CGO_ENABLED=0
WORKDIR /src
COPY go.mod go.sum /src/
RUN go mod download
COPY cmd/operator/main.go /src/
COPY pkg /src/pkg
COPY cmd/operator /src/cmd/operator
# Set arg/env after go mod download, otherwise we invalidate the cached layers due to the commit changing easily
ARG VERSION=0.0.0
ENV VERSION=${VERSION}
RUN go build -ldflags "-extldflags -static -w -s -X github.com/rancher/elemental-operator/version.Version=$VERSION" -o /usr/sbin/elemental-operator ./cmd/operator

FROM scratch as elemental-operator
COPY --from=build /usr/sbin/elemental-operator /usr/sbin/elemental-operator
ENTRYPOINT ["/usr/sbin/elemental-operator"]
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
GIT_COMMIT?=$(shell git rev-parse HEAD)
GIT_COMMIT_SHORT?=$(shell git rev-parse --short HEAD)
GIT_TAG?=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0" )
TAG?=${GIT_TAG}
REPO?=rancher/elemental-operator
TAG?=${GIT_TAG}-${GIT_COMMIT_SHORT}
REPO?=quay.io/costoolkit/elemental-operator-ci
export ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CHART?=$(shell find $(ROOT_DIR) -type f -name "elemental-operator*.tgz" -print)
CHART_VERSION?=$(subst v,,$(GIT_TAG))
KUBE_VERSION?="v1.22.7"
CLUSTER_NAME?="operator-e2e"

.PHONY: build
build: operator installer

.PHONY: operator
operator:
CGO_ENABLED=0 go build -ldflags "-extldflags -static -s -X 'github.com/rancher/elemental-operator/version.Version=$TAG'" -o build/elemental-operator $(ROOT_DIR)/cmd/operator
CGO_ENABLED=0 go build -ldflags "-extldflags -static -w -s -X 'github.com/rancher/elemental-operator/version.Version=$(TAG)'" -o build/elemental-operator $(ROOT_DIR)/cmd/operator

.PHONY: installer
installer:
CGO_ENABLED=0 go build -ldflags "-extldflags -static -s -X 'github.com/rancher/elemental-operator/version.Version=$TAG'" -o build/elemental-installer $(ROOT_DIR)/cmd/installer
CGO_ENABLED=0 go build -ldflags "-extldflags -static -w -s -X 'github.com/rancher/elemental-operator/version.Version=$(TAG)'" -o build/elemental-installer $(ROOT_DIR)/cmd/installer

.PHONY: build-docker
build-docker:
Expand All @@ -32,7 +34,11 @@ build-docker-push: build-docker
.PHONY: chart
chart:
mkdir -p $(ROOT_DIR)/build
helm package --version ${CHART_VERSION} --app-version ${GIT_TAG} -d $(ROOT_DIR)/build/ $(ROOT_DIR)/chart
cp -rf $(ROOT_DIR)/chart $(ROOT_DIR)/build/chart
sed -i -e 's/tag:.*/tag: '${TAG}'/' $(ROOT_DIR)/build/chart/values.yaml
sed -i -e 's|repository:.*|repository: '${REPO}'|' $(ROOT_DIR)/build/chart/values.yaml
helm package --version ${CHART_VERSION} --app-version ${GIT_TAG} -d $(ROOT_DIR)/build/ $(ROOT_DIR)/build/chart
rm -Rf $(ROOT_DIR)/build/chart

validate:
scripts/validate
Expand All @@ -41,5 +47,13 @@ unit-tests-deps:
go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@latest
go get github.com/onsi/gomega/...

unit-tests:
ginkgo -r -v --covermode=atomic --coverprofile=coverage.out ./pkg/...
.PHONY: unit-tests
unit-tests: unit-tests-deps
ginkgo -r -v --covermode=atomic --coverprofile=coverage.out -p -r ./pkg/...

e2e-tests:
KUBE_VERSION=${KUBE_VERSION} $(ROOT_DIR)/scripts/e2e-tests.sh

kind-e2e-tests: build-docker chart
kind load docker-image --name $(CLUSTER_NAME) ${REPO}:${TAG}
CHART=$(CHART) $(MAKE) e2e-tests
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Elemental operator can be added to a cluster running Rancher Multi Cluster
Management server. It is a helm chart and can be installed as follows:

```bash
helm -n cattle-rancheros-operator-system install --create-namespace rancheros-operator https://github.com/rancher-sandbox/rancheros-operator/releases/download/v0.1.0/rancheros-operator-0.1.0.tgz
helm -n cattle-elemental-operator-system install --create-namespace elemental-operator https://github.com/rancher/elemental-operator/releases/download/v0.1.0/elemental-operator-0.1.0.tgz
```

## Managing Upgrades
Expand Down
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ appVersion: 0.0.0
annotations:
catalog.cattle.io/certified: rancher
catalog.cattle.io/experimental: "true"
catalog.cattle.io/namespace: cattle-elemental-system
catalog.cattle.io/namespace: cattle-elemental-operator-system
catalog.cattle.io/release-name: elemental-operator
catalog.cattle.io/provides-gvr: elemental.cattle.io/v1
catalog.cattle.io/provides-gvr: elemental.cattle.io/v1beta1
catalog.cattle.io/os: linux
9 changes: 8 additions & 1 deletion chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ spec:
image: {{ template "system_default_registry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
args:
- operator
{{- if .Values.debug }}
- --debug
{{- end }}
- --namespace
- {{ .Release.Namespace }}
{{- if .Values.sync_namespaces}}
- --sync-namespaces
- {{ .Values.sync_namespaces }}
{{- end }}
- --sync-interval
- {{.Values.sync_interval }}
- --operator-image
- {{ template "system_default_registry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
- --default-registry
- {{ .Values.global.cattle.systemDefaultRegistry | quote }}
- --rancher-server-url
- {{ .Values.global.cattle.url }}
- {{ .Values.global.cattle.url | quote }}
- --ca-cert
- {{ .Values.global.cattle.ca_cert | quote }}
serviceAccountName: elemental-operator
Expand Down
6 changes: 6 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ global:
# default sync interval for upgrade channel
sync_interval: "60m"

# namespace the operator will watch for, leave empty for all
sync_namespaces: []

# enable debug output for operator
debug: false

nodeSelector:
kubernetes.io/os: linux

Expand Down
Loading

0 comments on commit 6a45f0b

Please sign in to comment.