Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
update build
Browse files Browse the repository at this point in the history
  • Loading branch information
rpahli committed Mar 20, 2020
1 parent 1fa213f commit e9e308b
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 13 deletions.
8 changes: 8 additions & 0 deletions .github/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
# the control plane node config
- role: control-plane
# the 2 workers
- role: worker
- role: worker
44 changes: 35 additions & 9 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,55 @@ name: Go

on: [push]

env:
CHANGE_MINIKUBE_NONE_USER: true
INSTALL_K8S_TOOLS: 1
IMG: kiwigrid/secret-replicator
jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.13
- name: Set up Go 1.12
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: 1.12
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
run: go get -v -t -d ./...

- name: Build
run: go build -v .
run: make

- name: Build Docker
run: make docker-build

install-chart:
name: install-chart
runs-on: ubuntu-latest
needs:
- build
strategy:
matrix:
k8s:
# assume no breaking changes between the version
- v1.12.10
- v1.17.2
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Create kind ${{ matrix.k8s }} cluster
uses: engineerd/[email protected]
with:
config: .github/kind-config.yaml
image: kindest/node:${{ matrix.k8s }}
- name: Run tests
env:
TEST_EXTERNAL_KUBE: true
run: make test
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
# COPY api/ api/
COPY controllers/ controllers/
COPY service/ service/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ generate: controller-gen
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."

# Build the docker image
docker-build: test
docker-build:
docker build . -t ${IMG}

# Push the docker image
Expand Down
17 changes: 15 additions & 2 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ limitations under the License.
package controllers

import (
"os"
"path/filepath"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"k8s.io/client-go/tools/clientcmd"

"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -50,8 +52,19 @@ var _ = BeforeSuite(func(done Done) {
logf.SetLogger(zap.LoggerTo(GinkgoWriter, true))

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},

if os.Getenv("TEST_EXTERNAL_KUBE") != "" {
existing := true
config, _ := clientcmd.BuildConfigFromFlags("", os.Getenv("KUBECONFIG"))
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
UseExistingCluster: &existing,
Config: config,
}
} else {
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
}
}

var err error
Expand Down
52 changes: 52 additions & 0 deletions tools/github/k8s-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# Copyright 2017-2018 IBM Corporation
#
# 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.
#

set -e

if [ -z "${INSTALL_K8S_TOOLS}" ]; then
exit 0
fi

if [ -z ${KUBECTL_VERSION+x} ]; then
KUBECTL_VERSION=v1.10.0
fi

if [ -z ${KB_VERSION+x} ]; then
KB_VERSION=1.0.5
fi

if [ -z ${KUSTOMIZE_VERSION+x} ]; then
KUSTOMIZE_VERSION=1.0.10
fi

echo "installing kubectl"
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/

echo "installing kubebuilder"
curl -SL "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KB_VERSION}/kubebuilder_${KB_VERSION}_linux_amd64.tar.gz" | tar xz
sudo mv kubebuilder_${KB_VERSION}_linux_amd64 /usr/local/kubebuilder
export KUBEBUILDER_ASSETS=/usr/local/kubebuilder/bin
sudo ln -s ${KUBEBUILDER_ASSETS}/kubebuilder /usr/local/bin/kubebuilder
kubebuilder version

echo "installing kustomize"
curl -OL "https://github.com/kubernetes-sigs/kustomize/releases/download/v${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64"
sudo chmod +x kustomize_${KUSTOMIZE_VERSION}_linux_amd64
sudo mv kustomize_${KUSTOMIZE_VERSION}_linux_amd64 /usr/local/bin/kustomize
kustomize version
63 changes: 63 additions & 0 deletions tools/github/minikube-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
#
# Copyright 2017-2018 IBM Corporation
#
# 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.
#

set -e

if [ -z "${INSTALL_MINIKUBE}" ]; then
exit 0
fi

MINIKUBE_VERSION=${MINIKUBE_VERSION:-v0.30.0}
BOOTSTRAPPER=${BOOTSTRAPPER:-kubeadm}
KUBE_VERSION=${KUBE_VERSION:-v1.11.0}

export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
export CHANGE_MINIKUBE_NONE_USER=true
export MINIKUBE_HOME=$HOME

echo "installing nsenter"
if ! which nsenter; then
curl -L https://github.com/minrk/git-crypt-bin/releases/download/trusty/nsenter > nsenter
chmod +x nsenter
sudo mv nsenter /usr/local/bin/
fi

# this is needed for kube > 1.11
echo "installing crictl"
curl -OL https://github.com/kubernetes-sigs/cri-tools/releases/download/${KUBE_VERSION}/crictl-${KUBE_VERSION}-linux-amd64.tar.gz
sudo tar zxvf crictl-${KUBE_VERSION}-linux-amd64.tar.gz -C /usr/local/bin
rm -f crictl-${KUBE_VERSION}-linux-amd64.tar.gz

echo "installing minikube"
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
chmod +x minikube
sudo mv minikube /usr/local/bin/

echo "starting minikube"
export KUBECONFIG=$HOME/.kube/config
sudo -E minikube start --vm-driver=none --bootstrapper=${BOOTSTRAPPER} --extra-config apiserver.authorization-mode=RBAC --kubernetes-version ${KUBE_VERSION}
echo "update context"
minikube update-context

echo "waiting minikube to be ready"
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';

until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True";
do
sleep 1;
done
12 changes: 12 additions & 0 deletions tools/github/start-kubeadm-dind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.

set -x

if [ -z "${INSTALL_DIND}" ]; then
exit 0
fi

# Install kubernetes-dind-cluster and boot it
wget https://cdn.rawgit.com/kubernetes-sigs/kubeadm-dind-cluster/master/fixed/dind-cluster-v$TRAVIS_KUBE_VERSION.sh -O $HOME/dind-cluster.sh && chmod +x $HOME/dind-cluster.sh && USE_HAIRPIN=true $HOME/dind-cluster.sh up

0 comments on commit e9e308b

Please sign in to comment.