Skip to content

Commit

Permalink
create/update/delete firewall rules for SQL servers (#148)
Browse files Browse the repository at this point in the history
* need to handled unexpected error types...like validation.error (#111)

* refactor tests  (#90)

* improve tests with parallel execution and rm sleep

* fix the tests to run on kindcluster

* Updates to KV controller from Ace (#80) (#112)

* feat: implement keyvault controller

* Ace's KV changes with updates

* Added an event for the final successful provisioning

* Updated changes based on the PR comments

* removing unwanted file

* making resource group name the one in the keyvault yaml

Co-authored-by: Ace Eldeib <alexeldeib@gmail.com>

* Test update (#115)

* this needs to exist in the reconciler in order to use controllerutil createorupdate

* Feat/add consumer group kind (#117)

* add consumer group kind

* update tests for consumer group

* fix isbeingdeleted

* Updates to README - steps for onboarding (#114)

* cluster additions

* updated docs

* Update azure-pipelines.yaml (#119)

* Update azure-pipelines.yaml

* fix tests (#140)

* revert back // +kubebuilder:subresource:status changes - fix broken tests

* Devcontainer to Help Onboard New People (#142)

* add dev conatiner - wip

* DevContainer up and running.

* Removed `sleep 80` and replaced with `kubectl wait`.

* Run `make set-kindcluster` from docker-compose.

* Set timeout on wait.

* Added `install-test-dependency` to makefile and dockerfile.

* Update README - Create SP with contribution rights.

* Updated README with details on using devcontainer.

* Stuff that wanted me to commit.

* Reverted changes made to `docker-build` in Makefile.

* pass future where possible instead of bool (#121)

* first commit on Amanda's branch

* first

* before properties

* test not tested

* test works

* unit tests work, needs firewall rules

* addresses feedback

* erin's feedback

* janani's change, pass future

* async works much better now

* janani feedback

* screwed up interface prototype

* firewall settings and unit tests

* firewall rule deletion
  • Loading branch information
WilliamMortlMicrosoft authored Aug 28, 2019
1 parent 006e683 commit 228c63d
Show file tree
Hide file tree
Showing 36 changed files with 1,900 additions and 263 deletions.
91 changes: 91 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

FROM golang:1.12.5

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# Configure apt, install packages and tools
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
#
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& apt-get -y install git procps lsb-release \
#
# Install gocode-gomod
&& go get -x -d github.com/stamblerre/gocode 2>&1 \
&& go build -o gocode-gomod github.com/stamblerre/gocode \
&& mv gocode-gomod $GOPATH/bin/ \
#
# Install Go tools
&& go get -u -v \
github.com/mdempsky/gocode \
github.com/uudashr/gopkgs/cmd/gopkgs \
github.com/ramya-rao-a/go-outline \
github.com/acroca/go-symbols \
github.com/godoctor/godoctor \
golang.org/x/tools/cmd/guru \
golang.org/x/tools/cmd/gorename \
github.com/rogpeppe/godef \
github.com/zmb3/gogetdoc \
github.com/haya14busa/goplay/cmd/goplay \
github.com/sqs/goreturns \
github.com/josharian/impl \
github.com/davidrjenni/reftools/cmd/fillstruct \
github.com/fatih/gomodifytags \
github.com/cweill/gotests/... \
golang.org/x/tools/cmd/goimports \
golang.org/x/lint/golint \
golang.org/x/tools/cmd/gopls \
github.com/alecthomas/gometalinter \
honnef.co/go/tools/... \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/mgechev/revive \
github.com/derekparker/delve/cmd/dlv 2>&1 \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update \
#
# Install Docker CE CLI
&& apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
&& apt-get update \
&& apt-get install -y docker-ce-cli \
#
# Install kubectl
&& curl -sSL -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \
&& chmod +x /usr/local/bin/kubectl \
#
# Install Helm
&& curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash -

# Verify git, process tools installed
RUN apt-get -y install git procps wget nano zsh inotify-tools jq
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true

ENV PATH="/usr/local/kubebuilder/bin:${PATH}"

ENV GO111MODULE=on

# Set the default shell to bash instead of sh
ENV AZURE_CLIENT_ID=""
ENV AZURE_CLIENT_SECRET=""
ENV AZURE_SUBSCRIPTION_ID=""
ENV AZURE_TENANT_ID=""
ENV KUBECONFIG="/root/.kube/kind-config-kind"

COPY ./Makefile ./
RUN make install-kind
RUN make install-kubebuilder
RUN make install-kustomize
RUN make install-test-dependency

ENV SHELL /bin/bash
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
"name": "Go",
"dockerComposeFile": "docker-compose.yml",
"service": "docker-in-docker",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose",
"extensions": [
"ms-azuretools.vscode-docker",
"ms-vscode.go"
],
"settings": {
"terminal.integrated.shell.linux": "zsh",
"go.gopath": "/go",
"go.inferGopath": true,
"go.useLanguageServer": true,
"go.toolsEnvVars": {
"GO111MODULE": "on"
},
"remote.extensionKind": {
"ms-azuretools.vscode-docker": "workspace"
}
}
}
24 changes: 24 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'
services:
docker-in-docker:
build:
context: ../
dockerfile: .devcontainer/Dockerfile
network_mode: "host"
ports:
- 5002:5001
volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- ..:/workspace

# This lets you avoid setting up Git again in the container
- ~/.gitconfig:/root/.gitconfig
- ~/.ssh:/root/.ssh:ro # does not work on Windows! Will need to generate in container :(
# Forwarding the socket is optional, but lets docker work inside the container if you install the Docker CLI.
# See the docker-in-docker-compose definition for details on how to install it.
- /var/run/docker.sock:/var/run/docker.sock

# Overrides default command so things don't shut down after the process ends - useful for debugging
command: bash -c "cd /workspace/ && make set-kindcluster && sleep infinity"
env_file:
- .env
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ testlogs.txt
.env
__debug_bin
.vscode
.devcontainer
.DS_Store
cover-existing.html
coverage-existing.txt
Expand Down
82 changes: 52 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
Expand Down Expand Up @@ -74,22 +73,7 @@ else
CONTROLLER_GEN=$(shell which controller-gen)
endif

set-kindcluster:
ifeq (,$(shell which kind))
@echo "installing kind"
GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0
else
@echo "kind has been installed"
endif
#KUBECONFIG=$(shell kind get kubeconfig-path --name="kind")
#$(shell export KUBECONFIG="$(kind get kubeconfig-path --name="kind")")
ifeq ($(shell kind get kubeconfig-path --name="kind"),$(KUBECONFIG))
@echo "kubeconfig-path points to kind path"
else
@echo "please run below command in your shell and then re-run make set-kindcluster"
@echo "\e[31mexport KUBECONFIG=$(shell kind get kubeconfig-path --name="kind")\e[0m"
@exit 111
endif
create-kindcluster:
ifeq (,$(shell kind get clusters))
@echo "no kind cluster"
else
Expand All @@ -98,10 +82,21 @@ else
endif
@echo "creating kind cluster"
kind create cluster
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"

set-kindcluster: install-kind
ifeq (${shell kind get kubeconfig-path --name="kind"},${KUBECONFIG})
@echo "kubeconfig-path points to kind path"
else
@echo "please run below command in your shell and then re-run make set-kindcluster"
@echo "\e[31mexport KUBECONFIG=$(shell kind get kubeconfig-path --name="kind")\e[0m"
@exit 111
endif
make create-kindcluster

@echo "getting value of KUBECONFIG"
kind get kubeconfig-path --name="kind"
@echo ${KUBECONFIG}
@echo "getting value of kind kubeconfig-path"

kubectl cluster-info
kubectl create namespace azureoperator-system
kubectl --namespace azureoperator-system \
Expand All @@ -111,33 +106,60 @@ endif
--from-literal=AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID} \
--from-literal=AZURE_TENANT_ID=${AZURE_TENANT_ID}

kubectl create namespace cert-manager
kubectl label namespace cert-manager certmanager.k8s.io/disable-validation=true
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v0.9.0/cert-manager.yaml
make install-cert-manager

#create image and load it into cluster
IMG="docker.io/controllertest:1" make docker-build
kind load docker-image docker.io/controllertest:1 --loglevel "trace"
make install
kubectl get namespaces
@echo "sleep 80 seconds to get the cert pods running"
sleep 80
@echo "end of sleep"
kubectl get pods --namespace cert-manager
@echo "Waiting for cert-manager to be ready"
kubectl wait pod -n cert-manager --for condition=ready --timeout=60s --all
@echo "all the pods should be running"
make deploy
sed -i'' -e 's@image: .*@image: '"IMAGE_URL"'@' ./config/default/manager_image_patch.yaml

install-kind:
ifeq (,$(shell which kind))
@echo "installing kind"
GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0
else
@echo "kind has been installed"
endif

install-kubebuilder:
ifeq (,$(shell which kubebuilder))
@echo "installing kubebuilder"
# download kubebuilder and extract it to tmp
curl -sL https://go.kubebuilder.io/dl/2.0.0-rc.0/$(shell go env GOOS)/$(shell go env GOARCH) | tar -xz -C /tmp/
# move to a long-term location and put it on your path
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
mv /tmp/kubebuilder_2.0.0-rc.0_$(shell go env GOOS)_$(shell go env GOARCH) /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
else
@echo "kubebuilder has been installed"
endif

install-kustomize:
ifeq (,$(shell which kustomize))
@echo "installing kustomize"
# download kustomize
sudo mkdir -p /usr/local/kustomize/
sudo curl -o /usr/local/kubebuilder/bin/kustomize -sL "https://go.kubebuilder.io/kustomize/$(shell go env GOOS)/$(shell go env GOARCH)"
curl -o /usr/local/kubebuilder/bin/kustomize -sL "https://go.kubebuilder.io/kustomize/$(shell go env GOOS)/$(shell go env GOARCH)"
# set permission
sudo chmod a+x /usr/local/kubebuilder/bin/kustomize
# export path
chmod a+x /usr/local/kubebuilder/bin/kustomize
$(shell which kustomize)

else
@echo "kustomize has been installed"
endif

install-cert-manager:
kubectl create namespace cert-manager
kubectl label namespace cert-manager certmanager.k8s.io/disable-validation=true
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v0.9.0/cert-manager.yaml

install-test-dependency:
go get -u github.com/jstemmer/go-junit-report \
&& go get github.com/axw/gocov/gocov \
&& go get github.com/AlekSi/gocov-xml \
&& go get golang.org/x/tools/cmd/cover
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ resources:
- group: azure
version: v1
kind: KeyVault
- group: azure
version: v1
kind: ConsumerGroup
Loading

0 comments on commit 228c63d

Please sign in to comment.