Skip to content

Commit

Permalink
Merge branch 'master' into g/conurrent_index
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored Mar 19, 2024
2 parents 00ee9ae + f528ae3 commit 72febbf
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 15 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/push-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ jobs:
- name: start minikube
id: minikube
uses: medyagh/setup-minikube@master
- uses: azure/setup-helm@v1
- uses: azure/setup-helm@v3
- name: install atlas-operator
run: |
helm install atlas-operator charts/atlas-operator --wait --set image.pullPolicy=Always
helm install atlas-operator charts/atlas-operator --wait \
--set image.pullPolicy=Always
- name: apply test resources
run: |
kubectl apply -k config/integration
Expand All @@ -46,6 +47,16 @@ jobs:
kubectl describe deployments
exit 1
fi
- name: test env vars
run: |
kubectl apply -k config/integration/env
helm upgrade atlas-operator charts/atlas-operator -f ./config/integration/env/values.yaml --wait
# Find the operator pod
OPERATOR=$(kubectl get pods -o jsonpath='{.items[0].metadata.name}')
# Extract the env from the operator pod
kubectl exec $OPERATOR -- env | grep NORMAL_ENV
kubectl exec $OPERATOR -- env | grep CONFIGMAP_REF_ENV
kubectl exec $OPERATOR -- env | grep SECRET_REF_ENV
helm-push:
name: Push to ghcr.io
needs: [helm-test]
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/push-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Fetch Atlas version
id: atlas
run: |
# All distributions are built from the same version
# so we only need to fetch it once.
echo "version=$(curl -s https://release.ariga.io/atlas/atlas-linux-amd64-latest.version)" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
Expand All @@ -46,6 +52,7 @@ jobs:
type=ref,event=branch
type=semver,pattern={{version}}
labels: |
io.ariga.atlas.version=${{ steps.atlas.outputs.version }}
org.opencontainers.image.title=atlas-operator
org.opencontainers.image.description=Atlas Operator
org.opencontainers.image.url=https://atlasgo.io
Expand All @@ -56,6 +63,7 @@ jobs:
with:
context: .
build-args: |
ATLAS_VERSION=${{ steps.atlas.outputs.version }}
OPERATOR_VERSION=v${{ steps.meta.outputs.version }}
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
Expand All @@ -73,4 +81,4 @@ jobs:
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
sarif_file: 'trivy-results.sarif'
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

# Build the manager binary
FROM golang:1.21.5-alpine as builder
FROM golang:1.21.6-alpine3.19 as builder
ARG TARGETOS
ARG TARGETARCH
ARG OPERATOR_VERSION
Expand All @@ -37,16 +37,20 @@ COPY internal/ internal/

RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \
-ldflags "-X 'main.version=${OPERATOR_VERSION}'" \
-a -o manager main.go
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} CGO_ENABLED=0 \
go build -ldflags "-X 'main.version=${OPERATOR_VERSION}'" \
-o manager -a main.go

FROM arigaio/atlas:latest-alpine as atlas
FROM alpine:3.19 as atlas
RUN apk add --no-cache curl
ARG ATLAS_VERSION=latest
ENV ATLAS_VERSION=${ATLAS_VERSION}
RUN curl -sSf https://atlasgo.sh | sh

FROM alpine:3.19.0
FROM alpine:3.19
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=atlas /atlas .
COPY --from=atlas /usr/local/bin/atlas .
RUN chmod +x /atlas
ENV ATLAS_NO_UPDATE_NOTIFIER=1
ENV ATLAS_KUBERNETES_OPERATOR=1
Expand Down
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,49 @@ To configure the operator, you can set the following values in the `values.yaml`

- `prewarmDevDB`: The Operator always keeps devdb resources around to speed up the migration process. Set this to `false` to disable this feature.

- `extraEnvs`: Used to set environment variables for the operator

```yaml
extraEnvs: []
# extraEnvs:
# - name: FOO
# value: "foo"
# - name: BAR
# valueFrom:
# secretKeyRef:
# key: BAR
# name: secret-resource
# - name: BAZ
# valueFrom:
# configMapKeyRef:
# key: BAZ
# name: configmap-resource
```

- `extraVolumes`: Used to mount additional volumes to the operator

```yaml
extraVolumes: []
# extraVolumes:
# - name: my-volume
# secret:
# secretName: my-secret
# - name: my-volume
# configMap:
# name: my-configmap
```

- `extraVolumeMounts`: Used to mount additional volumes to the operator

```yaml
extraVolumeMounts: []
# extraVolumeMounts:
# - name: my-volume
# mountPath: /path/to/mount
# - name: my-volume
# mountPath: /path/to/mount
```

### Getting started

In this example, we will create a MySQL database and apply a schema to it. After installing the
Expand Down
4 changes: 2 additions & 2 deletions charts/atlas-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: atlas-operator
description: The Atlas Kubernetes Operator
type: application
version: 0.3.9
appVersion: 0.3.9
version: 0.4.2
appVersion: 0.4.2
18 changes: 16 additions & 2 deletions charts/atlas-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ spec:
labels:
control-plane: controller-manager
{{- include "atlas-operator.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
kubectl.kubernetes.io/default-container: manager
{{- end }}
spec:
{{- with .Values.extraVolumes }}
volumes:
{{- toYaml . | nindent 6 }}
{{- end }}
containers:
- image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
Expand All @@ -42,12 +49,19 @@ spec:
initialDelaySeconds: 5
periodSeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- toYaml .Values.resources | nindent 10 }}
securityContext:
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
{{- toYaml .Values.containerSecurityContext | nindent 10 }}
env:
- name: PREWARM_DEVDB
value: "{{ .Values.prewarmDevDB }}"
{{- with .Values.extraEnvs }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.extraVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/atlas-operator/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ metadata:
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: atlas-operator
app.kubernetes.io/part-of: atlas-operator
{{- with .Values.serviceAccount.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "atlas-operator.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
Expand Down
32 changes: 31 additions & 1 deletion charts/atlas-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ fullnameOverride: ""
serviceAccount:
create: true
annotations: {}
labels: {}
name: ""

podAnnotations: {}

podLabels: {}

podSecurityContext:
runAsNonRoot: true

Expand All @@ -43,4 +46,31 @@ affinity: {}

# By default, the operator will recreate devdb pods after migration
# Set this to true to keep the devdb pods around.
prewarmDevDB: true
prewarmDevDB: true

# -- Additional environment variables to set
extraEnvs: []
# extraEnvs:
# - name: FOO
# valueFrom:
# secretKeyRef:
# key: FOO
# name: secret-resource
# - name: BAR
# valueFrom:
# configMapKeyRef:
# key: BAR
# name: config-map-resource

extraVolumes: []
# extraVolumes:
# - name: extra-volume
# secret:
# secretName: extra-volume-secret

extraVolumeMounts: []
# extraVolumeMounts:
# - name: extra-volume
# mountPath: /extra-volume
# readOnly: true

20 changes: 20 additions & 0 deletions config/integration/env/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

kind: ConfigMap
apiVersion: v1
metadata:
name: "operator-env-configmap"
data:
CONFIGMAP_REF_ENV: "value"
19 changes: 19 additions & 0 deletions config/integration/env/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

## Append samples you want in your CSV to this file as resources ##
resources:
- configmap.yaml
- secret.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
21 changes: 21 additions & 0 deletions config/integration/env/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Secret
metadata:
name: "operator-env-secret"
type: Opaque
data:
SECRET_REF_ENV: "dmFsdWU="
27 changes: 27 additions & 0 deletions config/integration/env/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

extraEnvs:
- name: NORMAL_ENV
value: "value"
- name: SECRET_REF_ENV
valueFrom:
secretKeyRef:
key: SECRET_REF_ENV
name: operator-env-secret
- name: CONFIGMAP_REF_ENV
valueFrom:
configMapKeyRef:
key: CONFIGMAP_REF_ENV
name: operator-env-configmap

0 comments on commit 72febbf

Please sign in to comment.