Skip to content

Commit c68ceea

Browse files
authored
Upgrade operator-sdk version (#117)
Big migration to the latest operator-framework version. Key features * Deployment with an tarantool-operator is launched in a separate namespace. * The crd's api version has been updated from `apiextensions.k8s.io/v1beta1` to `apiextensions.k8s.io/v1`. * This means that you can now use new kubernetes versions (1.21 and higher). Also * Fix gh-actions CI testing. * helm charts (they are now in the same directory ./helm-charts/). * README.md (combed examples and added links to documentation). * Makefile with convenient utilities. * Simple e2e tests with a real cluster in CI.
1 parent 74d6e58 commit c68ceea

File tree

156 files changed

+27797
-3885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+27797
-3885
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2+
# Ignore build and test binaries.
13
.git/
2-
4+
bin/
5+
testbin/

.github/workflows/test.yml

Lines changed: 108 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,132 @@ jobs:
1010

1111
- name: lint
1212
uses: golangci/golangci-lint-action@v2
13+
with:
14+
args: --timeout 2m
1315

14-
testing:
15-
name: testing
16+
controllers_testing:
17+
name: controllers_testing
1618
runs-on: ubuntu-latest
1719
needs: lint
18-
env:
19-
OPERATOR_SDK_VERSION: v0.12.0
20-
20+
2121
strategy:
2222
matrix:
23-
kubernetes-version: [v1.16.4, v1.19.4]
23+
kubebuilder-version: [1.16.4, 1.22.1]
2424

2525
steps:
2626
- uses: actions/checkout@v1
2727

28-
- name: Set up Go 1.13
28+
- name: Set up Go 1.17
2929
uses: actions/setup-go@v1
3030
with:
31-
go-version: 1.13
31+
go-version: 1.17
3232
id: go
3333

34-
- name: Set up Kind k8s Cluster
35-
uses: helm/kind-action@v1.1.0
36-
with:
37-
node_image: kindest/node:${{ matrix.kubernetes-version }}
38-
3934
- name: Set up Kubebuilder
4035
run: |
4136
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
4237
ARCH=$(uname -m | sed 's/x86_64/amd64/')
43-
curl -fsL "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-1.16.4-${OS}-${ARCH}.tar.gz" -o kubebuilder-tools
38+
curl -fsL "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-${{matrix.kubebuilder-version}}-${OS}-${ARCH}.tar.gz" -o kubebuilder-tools
4439
tar -zvxf kubebuilder-tools
4540
sudo mv kubebuilder/ /usr/local/kubebuilder
4641
47-
- name: Install modules
48-
run: go mod download
49-
5042
- name: Test
51-
run: go test -v ./pkg/... -cover
43+
run: make test ENVTEST_K8S_VERSION=${{matrix.kubebuilder-version}}
44+
45+
e2e_testing:
46+
name: e2e_testing
47+
runs-on: ubuntu-latest
48+
needs: lint
49+
env:
50+
KIND_CLUSTER_NAME: kind-cluster
51+
OPERATOR_NAMESPACE: tarantool-operator
52+
APP_NAMESPACE: tarantool-app
53+
OPERATOR_IMAGE_REPO: tarantool-operator
54+
OPERATOR_IMAGE_TAG: 0.0.0
55+
56+
strategy:
57+
matrix:
58+
kubernetes-version: [v1.16.2, v1.16.4, v1.19.4, v1.22.4]
59+
60+
steps:
61+
- uses: actions/checkout@v1
62+
63+
- name: Set up helm
64+
uses: azure/setup-helm@v1
65+
66+
- name: Set up Kind Cluster
67+
uses: helm/kind-action@v1.2.0
68+
with:
69+
node_image: kindest/node:${{ matrix.kubernetes-version }}
70+
cluster_name: ${{ env.KIND_CLUSTER_NAME }}
71+
72+
- name: Prepare Tarantool operator Docker image
73+
run: |
74+
make docker-build REPO=${{ env.OPERATOR_IMAGE_REPO }} VERSION=${{ env.OPERATOR_IMAGE_TAG }}
75+
kind load docker-image ${{ env.OPERATOR_IMAGE_REPO }}:${{ env.OPERATOR_IMAGE_TAG }} \
76+
--name ${{ env.KIND_CLUSTER_NAME }}
77+
78+
- name: Install Tarantool Operator in Kind
79+
run: |
80+
# Set the default namespace
81+
kubectl config set-context --current --namespace=${{ env.OPERATOR_NAMESPACE }}
82+
83+
helm install -n ${{ env.OPERATOR_NAMESPACE }} operator helm-charts/tarantool-operator \
84+
--create-namespace \
85+
--set image.repository=${{ env.OPERATOR_IMAGE_REPO }} \
86+
--set image.tag=${{ env.OPERATOR_IMAGE_TAG }}
87+
88+
- name: Waiting for Operator Deployment availability
89+
run: kubectl wait deployment/controller-manager --for=condition=available --timeout=60s || true
90+
91+
- name: Сhecking the number of available replicas
92+
run: |
93+
available_num=$(kubectl get deployments/controller-manager -o=jsonpath="{.status.availableReplicas}")
94+
desired_num=$(kubectl get deployments/controller-manager -o=jsonpath="{.status.replicas}")
95+
96+
if [[ $available_num -ne $desired_num ]]; then
97+
kubectl describe deployments/controller-manager
98+
echo 'ERROR: invalid number of available replicas...' >&2; exit 1
99+
fi
100+
101+
- name: Install Tarantool Cartridge app in Kind
102+
run: |
103+
# Set the default namespace
104+
kubectl config set-context --current --namespace=${{ env.APP_NAMESPACE }}
105+
106+
helm install -n ${{ env.APP_NAMESPACE }} --create-namespace \
107+
-f test/helpers/ci/cluster_values.yaml \
108+
cartridge-app \
109+
helm-charts/tarantool-cartridge
110+
111+
- name: Waiting for routers Pods availability
112+
run: kubectl wait --for=condition=ready pod --timeout=180s -l tarantool.io/role=router || true
113+
114+
- name: Сhecking the number of ready router replicas
115+
run : |
116+
desired_routers_num=1
117+
ready_routers_num=$(kubectl get statefulsets/router-0 -o=jsonpath="{.status.readyReplicas}")
118+
119+
if [[ $ready_routers_num -ne $desired_routers_num ]]; then
120+
kubectl describe statefulsets/router-0
121+
kubectl describe pod -l tarantool.io/role=router
122+
echo 'ERROR: invalid number of ready routers...' >&2; exit 1
123+
fi
124+
125+
- name: Waiting for storages availability
126+
run: kubectl wait --for=condition=ready pod --timeout=180s -l tarantool.io/role=storage || true
127+
128+
- name: Сhecking the number of ready storage replicas
129+
run: |
130+
desired_storage_num=1
131+
ready_storage_num=$(kubectl get statefulsets/storage-0 -o=jsonpath="{.status.readyReplicas}")
132+
133+
if [[ $ready_storage_num -ne $desired_storage_num ]]; then
134+
kubectl describe statefulsets/storage-0
135+
kubectl describe pod -l tarantool.io/role=storage
136+
echo 'ERROR: invalid number of ready storages...' >&2; exit 1
137+
fi
138+
139+
140+
141+

.gitignore

Lines changed: 16 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,27 @@
1-
# Temporary Build Files
2-
build/_output
3-
build/_test
4-
# Created by https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
5-
### Emacs ###
6-
# -*- mode: gitignore; -*-
7-
*~
8-
\#*\#
9-
/.emacs.desktop
10-
/.emacs.desktop.lock
11-
*.elc
12-
auto-save-list
13-
tramp
14-
.\#*
15-
# Org-mode
16-
.org-id-locations
17-
*_archive
18-
# flymake-mode
19-
*_flymake.*
20-
# eshell files
21-
/eshell/history
22-
/eshell/lastdir
23-
# elpa packages
24-
/elpa/
25-
# reftex files
26-
*.rel
27-
# AUCTeX auto folder
28-
/auto/
29-
# cask packages
30-
.cask/
31-
dist/
32-
# Flycheck
33-
flycheck_*.el
34-
# server auth directory
35-
/server/
36-
# projectiles files
37-
.projectile
38-
projectile-bookmarks.eld
39-
# directory configuration
40-
.dir-locals.el
41-
# saveplace
42-
places
43-
# url cache
44-
url/cache/
45-
# cedet
46-
ede-projects.el
47-
# smex
48-
smex-items
49-
# company-statistics
50-
company-statistics-cache.el
51-
# anaconda-mode
52-
anaconda-mode/
53-
### Go ###
1+
542
# Binaries for programs and plugins
553
*.exe
564
*.exe~
575
*.dll
586
*.so
597
*.dylib
60-
# Test binary, build with 'go test -c'
8+
bin
9+
testbin/*
10+
11+
# Test binary, build with `go test -c`
6112
*.test
13+
6214
# Output of the go coverage tool, specifically when used with LiteIDE
6315
*.out
64-
### Vim ###
65-
# swap
66-
.sw[a-p]
67-
.*.sw[a-p]
68-
# session
69-
Session.vim
70-
# temporary
71-
.netrwhist
72-
# auto-generated tag files
73-
tags
74-
### VisualStudioCode ###
75-
.vscode/*
76-
.history
77-
### MacOS specific ###
78-
.DS_Store
79-
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
80-
kubeconfig.yaml
81-
./deployment.yaml
82-
./tarantool-operator
83-
helm_values.yaml
84-
deploy/*
8516

86-
ci/helm-chart/templates/crds/tarantool.io_*s_crd.yaml
87-
ci/helm-chart/templates/crds/tarantool_*_cr.yaml
17+
# Kubernetes Generated files - skip generated files, except for vendored files
18+
19+
!vendor/**/zz_generated.*
20+
21+
# editor and IDE paraphernalia
22+
.idea
23+
*.swp
24+
*.swo
25+
*~
8826

89-
doc/locale/en/
90-
doc/output/
27+
*.DS_Store

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10-
## [0.0.8] - 2021-03-30
10+
### Added
11+
- Makefile with a full set of targets for all occasions
12+
13+
### Changed
14+
- The Tarantool Operator is installed in a separate namespace
15+
- Bump operator-sdk version (and other dependencies)
16+
- Refactor project structure, all helm charts are collected in one place
17+
- Update crds api version from `apiextensions.k8s.io/v1beta1` to `apiextensions.k8s.io/v1`
18+
19+
## [0.0.9] - 2021-03-30
1120

1221
### Added
1322
- Integration test for cluster_controller written with envtest and ginkgo

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build the manager binary
2+
FROM golang:1.16 as builder
3+
4+
WORKDIR /workspace
5+
# Copy the Go Modules manifests
6+
COPY go.mod go.mod
7+
COPY go.sum go.sum
8+
# cache deps before building and copying source so that we don't need to re-download as much
9+
# and so that source changes don't invalidate our downloaded layer
10+
RUN go mod download
11+
12+
# Copy the go source
13+
COPY main.go main.go
14+
COPY api/ api/
15+
COPY controllers/ controllers/
16+
17+
# Build
18+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
19+
20+
# Use distroless as minimal base image to package the manager binary
21+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
22+
FROM gcr.io/distroless/static:nonroot
23+
WORKDIR /
24+
COPY --from=builder /workspace/manager .
25+
USER 65532:65532
26+
27+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)