-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Ci implementation (#1) * added github workflow, minor fixes in configloader * Multi arch build (#2) * multi architecture build * increase ci job timeout * module path changed * Deploy kustomize (#3) * kustomize image tag * added custom-env for manager * Linter warnings (#4) * linter warnings fixes * fixed respBodyClose func in api_handler and ctrl returns in controller * added awesome full yaml in samples * rm vaMode from sample vnet yaml * Ci release (#7) * Makefile clean-up * added release in makefile && release workflow for tags * makefile release add image tag * fixes #6 * added VNet sample * vnet readme fix * Vnet sample (#8) * added VNet sample * vnet readme fix * update vnet sample * Update README.md * vnet dev v1alpha1 (#12) * vnet-dev initial commit * controller-api full link * fix: change Netris API module to 'netris-api-go' * Update main.yml * Update main.yml * Update main.yml * change netris api package name * change netris api package name * refactor: reconcile cycle improvements * refactor: change file structure * feat: add netris data storage * add licenses * feat: add netris data storage Co-authored-by: Artashes Balabekyan <[email protected]> * added helm chart (#13) * chart init * added rbac in helm chart * added rbac to helm template script * fix deployment and service in helm chart * refactor: update required fields * CI fix (#14) * added ssh-key in main CI * added GIT_AUTH_TOKEN in main ci Build and push step * added experimental key mount in dockerfile * debuging * fix ssh key in docker buildkit * ssh_private_key_ci full path in docker buildkit * dockerfile fixes * cleanup and prepared for release * fixed release CI * CI Release steps reorder * fix: if port is untagged set vlanID to 1 * fix: don't requeue after create * fix: change the order of checks in reconcile function * deploy readme fix * deploy readme fix * deploy readme fix * Netris Helm repository (#15) * update helm-repo from makefile helm target * Update deploy README * change go version to 1.14 * update netrisapi package version in go.mod * TLS insecure option functionality * Vnetmeta (#16) added vnetmeta kind Co-authored-by: Artashes Balabekyan <[email protected]> * updateted Helm * refactor: use logger for log messages * fix: deletion logic. don't use finalizer for vnetmeta CR * fix: deletion logic. don't use finalizer for vnetmeta CR. Update netrisapi module * feat: log after vnet is deleted * refactor: requeue option, logging mechanism. Support requeue option. Don't exit with error from reconciler, return nil and requeue. * comment: comment Cred and NStorage datastrucutres * added logger and requeue option * add branches in CI job * CI only for tags * fix helm NOPERATOR_DEV_MODE env * UP deplot readme tag * fix: set provisioning field to 1, and state field to previous field * up appVersion * helm version up * Update README.md * Update README.md * fix: set the state is 'active' when not defined in yaml * fix: handle the switchPort state field * fix: gateways and switchPorts fields are not mandatory * feat: when 'netris.imported' is true in annotations, identify vnet by name instead of creating new one. * info log when not imported * fix: change guestTenants type to string * update netris api package. fix: handle guestTenants field * refactor: change gateways structure and calculation * fix: use requeueInterval for reconcile period * added ebgp sample yaml (#18) * fix: netris import flag name in annotations * added resource importing Co-authored-by: Artashes Balabekyan <[email protected]> Co-authored-by: asaroyan <[email protected]>
- Loading branch information
1 parent
4f6eebe
commit c097bdc
Showing
57 changed files
with
3,293 additions
and
547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Test, Build and Push | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Git configs and known_hosts | ||
run: | | ||
export known_hosts=$(ssh-keyscan github.com) | ||
git config --global --add url."[email protected]:".insteadOf "https://github.com/" | ||
- name: Install SSH key | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.SSH_PRIVATE_KEY_NETRISAPI }} | ||
known_hosts: ${known_hosts} | ||
|
||
- name: Switch the default system shell | ||
run: sudo rm /bin/sh; sudo ln -s bash /bin/sh | ||
|
||
- name: Make test | ||
run: CONTROLLER_HOST="example.com" make test | ||
|
||
- name: Prepare | ||
id: prep | ||
run: | | ||
DOCKER_IMAGE=${GITHUB_REPOSITORY} | ||
VERSION=edge | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
elif [[ $GITHUB_REF == refs/heads/* ]]; then | ||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | ||
elif [[ $GITHUB_REF == refs/pull/* ]]; then | ||
VERSION=pr-${{ github.event.number }} | ||
fi | ||
TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
if [ "${{ github.event_name }}" = "push" ]; then | ||
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" | ||
fi | ||
echo ::set-output name=version::${VERSION} | ||
echo ::set-output name=tags::${TAGS} | ||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.prep.outputs.tags }} | ||
ssh: | | ||
ssh_private_key_ci=/home/runner/.ssh/id_rsa | ||
labels: | | ||
org.opencontainers.image.source=${{ github.event.repository.html_url }} | ||
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | ||
org.opencontainers.image.revision=${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Create release | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
jobs: | ||
build: | ||
name: Upload Release Asset | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Git configs and known_hosts | ||
run: | | ||
export known_hosts=$(ssh-keyscan github.com) | ||
git config --global --add url."[email protected]:".insteadOf "https://github.com/" | ||
- name: Install SSH key | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.SSH_PRIVATE_KEY_NETRISAPI }} | ||
known_hosts: ${known_hosts} | ||
- name: Generate Manifests | ||
run: make release | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | ||
asset_path: ./deploy/netris-operator.yaml | ||
asset_name: netris-operator.yaml | ||
asset_content_type: text/yaml | ||
- name: Upload Release Asset - CRD | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | ||
asset_path: ./deploy/netris-operator.crds.yaml | ||
asset_name: netris-operator.crds.yaml | ||
asset_content_type: text/yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ bin | |
*.swp | ||
*.swo | ||
*~ | ||
.netrc | ||
testbin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
# syntax=docker/dockerfile:experimental | ||
# Build the manager binary | ||
FROM golang:1.13 as builder | ||
|
||
WORKDIR /workspace | ||
|
||
# Config ssh private key | ||
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
RUN git config --global --add url."[email protected]:".insteadOf "https://github.com/" | ||
|
||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
RUN --mount=type=ssh,id=ssh_private_key_ci go mod download | ||
|
||
# Copy the go source | ||
COPY main.go main.go | ||
COPY api/ api/ | ||
COPY controllers/ controllers/ | ||
COPY configloader/ configloader/ | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go | ||
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o manager main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
# Current Operator version | ||
VERSION ?= 0.0.1 | ||
# Default bundle image tag | ||
BUNDLE_IMG ?= controller-bundle:$(VERSION) | ||
# Options for 'bundle-build' | ||
ifneq ($(origin CHANNELS), undefined) | ||
BUNDLE_CHANNELS := --channels=$(CHANNELS) | ||
endif | ||
ifneq ($(origin DEFAULT_CHANNEL), undefined) | ||
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) | ||
# Capture image tag from git branch name | ||
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || true) | ||
ifeq (,$(GIT_BRANCH)) | ||
TAG = latest | ||
else ifeq (master, $(GIT_BRANCH)) | ||
TAG = latest | ||
else ifeq (HEAD, $(GIT_BRANCH)) | ||
TAG = $(shell git describe --abbrev=0 --tags $(shell git rev-list --abbrev-commit --tags --max-count=1) 2> /dev/null || true) | ||
else | ||
TAG = $(GIT_BRANCH) | ||
endif | ||
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= controller:latest | ||
IMG ?= netrisai/netris-operator:$(TAG) | ||
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:trivialVersions=true" | ||
|
||
|
@@ -53,6 +52,9 @@ deploy: manifests kustomize | |
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
$(KUSTOMIZE) build config/default | kubectl apply -f - | ||
|
||
undeploy: | ||
$(KUSTOMIZE) build config/default | kubectl delete -f - | ||
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
manifests: controller-gen | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
@@ -109,15 +111,30 @@ else | |
KUSTOMIZE=$(shell which kustomize) | ||
endif | ||
|
||
# Generate bundle manifests and metadata, then validate generated files. | ||
.PHONY: bundle | ||
bundle: manifests kustomize | ||
operator-sdk generate kustomize manifests -q | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) | ||
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) | ||
operator-sdk bundle validate ./bundle | ||
|
||
# Build the bundle image. | ||
.PHONY: bundle-build | ||
bundle-build: | ||
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . | ||
release: generate fmt vet manifests kustomize | ||
$(KUSTOMIZE) build config/crd > deploy/netris-operator.crds.yaml | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
$(KUSTOMIZE) build config/default > deploy/netris-operator.yaml | ||
|
||
pip-install-reqs: | ||
pip3 install yq pyyaml | ||
|
||
helm: generate fmt vet manifests pip-install-reqs | ||
mkdir -p deploy/charts/netris-operator/crds/ | ||
cp config/crd/bases/* deploy/charts/netris-operator/crds/ | ||
echo "{{- if .Values.rbac.create -}}" > deploy/charts/netris-operator/templates/rbac.yaml | ||
for i in $(shell yq -y .resources config/rbac/kustomization.yaml | awk {'print $$2'});\ | ||
do echo "---" >> deploy/charts/netris-operator/templates/rbac.yaml && \ | ||
scripts/rbac-helm-template.py config/rbac/$${i} | yq -y . >> deploy/charts/netris-operator/templates/rbac.yaml;\ | ||
done | ||
echo "{{- end }}" >> deploy/charts/netris-operator/templates/rbac.yaml | ||
@{ \ | ||
set -e ;\ | ||
HELM_CHART_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
git clone [email protected]:netrisai/charts.git --depth 1 $$HELM_CHART_GEN_TMP_DIR ;\ | ||
if [[ -z "$${HELM_CHART_REPO_COMMIT_MSG}" ]]; then HELM_CHART_REPO_COMMIT_MSG=Update-$$(date '+%F_%T' -u); fi ;\ | ||
cp -r deploy/charts $$HELM_CHART_GEN_TMP_DIR ;\ | ||
cd $$HELM_CHART_GEN_TMP_DIR ;\ | ||
git add charts && git commit -m $$HELM_CHART_REPO_COMMIT_MSG && git push -u origin main ;\ | ||
rm -rf $$HELM_CHART_GEN_TMP_DIR ;\ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
domain: netris.ai | ||
layout: go.kubebuilder.io/v2 | ||
projectName: netris-operator | ||
repo: github.com/netrisx/netris-operator | ||
repo: github.com/netrisai/netris-operator | ||
resources: | ||
- group: k8s | ||
kind: VNet | ||
version: v1alpha1 | ||
- group: k8s | ||
kind: VNetMeta | ||
version: v1alpha1 | ||
version: 3-alpha | ||
plugins: | ||
go.sdk.operatorframework.io/v2-alpha: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.