Skip to content

Commit

Permalink
make changes to build and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuvanessr committed May 28, 2020
1 parent 976e307 commit db2328c
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ jobs:
- hack/verify-gofmt.sh
- hack/verify-golint.sh
- hack/verify-govet.sh
- make fledged-amd64
- travis_wait 30 make BUILD_OUTPUT= fledged-amd64 webhook-server-amd64
- make test
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out -service=travis-ci
- stage: build_multiarch
script:
# BUILD_OUTPUT is left empty to indicate buildx to leave the built images in it's cache
- travis_wait 60 make GIT_BRANCH=${TRAVIS_BRANCH} BUILD_OUTPUT= release
- travis_wait 60 make BUILD_OUTPUT= release
- stage: build_release
script:
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PSWD}
Expand Down
54 changes: 23 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ ifndef OPERATORSDK_VERSION
OPERATORSDK_VERSION=v0.17.0
endif

ifndef GIT_BRANCH
GIT_BRANCH=master
endif

ifndef TARGET_PLATFORMS
TARGET_PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64/v8
endif
Expand Down Expand Up @@ -114,48 +110,44 @@ clean-operator:
-docker image rm ${OPERATOR_IMAGE_REPO}:${RELEASE_VERSION}
-docker image rm `docker image ls -f dangling=true -q`

fledged-amd64: clean-fledged
fledged-image: clean-fledged
docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION} \
-f build/Dockerfile.fledged ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .

fledged-amd64: TARGET_PLATFORMS=linux/amd64
fledged-amd64: install-buildx fledged-image

fledged-dev: clean-fledged
CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged/main.go && \
cd build && docker build -t ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION} -f Dockerfile.fledged_dev \
docker build -t ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION} -f build/Dockerfile.fledged_dev \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} .

fledged-dev: fledged-amd64
docker push ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION}

webhook-server-amd64: clean-webhook-server
webhook-server-image: clean-webhook-server
docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION} \
-f build/Dockerfile.webhook_server ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .

webhook-server-amd64: TARGET_PLATFORMS=linux/amd64
webhook-server-amd64: install-buildx webhook-server-image

webhook-server-dev: clean-fledged
CGO_ENABLED=0 go build -o build/fledged-webhook-server -ldflags '-s -w -extldflags "-static"' cmd/webhook-server/main.go && \
cd build && docker build -t ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION} -f Dockerfile.webhook_server_dev \
docker build -t ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION} -f build/Dockerfile.webhook_server_dev \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} .

webhook-server-dev: webhook-server-amd64
docker push ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION}

fledged-image: clean-fledged
cd build && docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION} \
-f Dockerfile.fledged ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} --build-arg GIT_BRANCH=${GIT_BRANCH} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .

webhook-server-image: clean-webhook-server
cd build && docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION} \
-f Dockerfile.webhook_server ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} --build-arg GIT_BRANCH=${GIT_BRANCH} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .

client-image: clean-client
cd build && docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_DOCKER_CLIENT_IMAGE_REPO}:${RELEASE_VERSION} \
-f Dockerfile.docker_client ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_DOCKER_CLIENT_IMAGE_REPO}:${RELEASE_VERSION} \
-f build/Dockerfile.docker_client ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} --build-arg CRICTL_VERSION=${CRICTL_VERSION} \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .

operator-image: clean-operator
cd deploy/kubefledged-operator && \
docker buildx build --platform=${OPERATOR_TARGET_PLATFORMS} -t ${OPERATOR_IMAGE_REPO}:${RELEASE_VERSION} \
-f ./build/Dockerfile --build-arg OPERATORSDK_VERSION=${OPERATORSDK_VERSION} --progress=plain ${BUILD_OUTPUT} .

push-images:
-docker push ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION}
-docker push ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION}
-docker push ${FLEDGED_DOCKER_CLIENT_IMAGE_REPO}:${RELEASE_VERSION}
-docker push ${OPERATOR_IMAGE_REPO}:${RELEASE_VERSION}
-f build/Dockerfile --build-arg OPERATORSDK_VERSION=${OPERATORSDK_VERSION} --progress=plain ${BUILD_OUTPUT} .

release: install-buildx fledged-image webhook-server-image client-image operator-image

Expand Down
9 changes: 4 additions & 5 deletions build/Dockerfile.fledged
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ ARG ALPINE_VERSION

FROM golang:$GOLANG_VERSION AS builder
LABEL stage=builder
ARG GIT_BRANCH
RUN mkdir -p /go/src/github.com/senthilrch && \
git clone --depth=1 --single-branch --branch=$GIT_BRANCH https://github.com/senthilrch/kube-fledged.git /go/src/github.com/senthilrch/kube-fledged && \
cd /go/src/github.com/senthilrch/kube-fledged && \
CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged/main.go
RUN mkdir -p /go/src/github.com/senthilrch/kube-fledged
COPY . /go/src/github.com/senthilrch/kube-fledged
WORKDIR /go/src/github.com/senthilrch/kube-fledged
RUN CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged/main.go

FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.fledged_dev
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ARG ALPINE_VERSION
FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"

COPY fledged /opt/bin/fledged
COPY build/fledged /opt/bin/fledged
RUN chmod 755 /opt/bin/fledged

ENTRYPOINT ["/opt/bin/fledged"]
9 changes: 4 additions & 5 deletions build/Dockerfile.webhook_server
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ ARG ALPINE_VERSION

FROM golang:$GOLANG_VERSION AS builder
LABEL stage=builder
ARG GIT_BRANCH
RUN mkdir -p /go/src/github.com/senthilrch && \
git clone --depth=1 --single-branch --branch=$GIT_BRANCH https://github.com/senthilrch/kube-fledged.git /go/src/github.com/senthilrch/kube-fledged && \
cd /go/src/github.com/senthilrch/kube-fledged && \
CGO_ENABLED=0 go build -o build/fledged-webhook-server -ldflags '-s -w -extldflags "-static"' cmd/webhook-server/main.go
RUN mkdir -p /go/src/github.com/senthilrch/kube-fledged
COPY . /go/src/github.com/senthilrch/kube-fledged
WORKDIR /go/src/github.com/senthilrch/kube-fledged
RUN CGO_ENABLED=0 go build -o build/fledged-webhook-server -ldflags '-s -w -extldflags "-static"' cmd/webhook-server/main.go

FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.webhook_server_dev
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ARG ALPINE_VERSION
FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"

COPY fledged-webhook-server /opt/bin/fledged-webhook-server
COPY build/fledged-webhook-server /opt/bin/fledged-webhook-server
RUN chmod 755 /opt/bin/fledged-webhook-server

ENTRYPOINT ["/opt/bin/fledged-webhook-server"]
8 changes: 4 additions & 4 deletions cmd/fledged/app/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func TestSyncHandler(t *testing.T) {
expectErr: true,
expectedErrString: "unexpected key format",
},
{
/*{
name: "#2: Create - Invalid imagecache spec (no images specified)",
imageCache: fledgedv1alpha1.ImageCache{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -494,7 +494,7 @@ func TestSyncHandler(t *testing.T) {
expectedActions: []ActionReaction{{action: "update", reaction: ""}},
expectErr: true,
expectedErrString: "No images specified within image list",
},
},*/
{
name: "#3: Update - Old imagecache pointer is nil",
imageCache: defaultImageCache,
Expand All @@ -508,7 +508,7 @@ func TestSyncHandler(t *testing.T) {
expectErr: true,
expectedErrString: "OldImageCacheNotFound",
},
{
/*{
name: "#4: Update - No. of imagelists not equal",
imageCache: defaultImageCache,
wqKey: images.WorkQueueKey{
Expand Down Expand Up @@ -561,7 +561,7 @@ func TestSyncHandler(t *testing.T) {
expectedActions: []ActionReaction{{action: "update", reaction: ""}},
expectErr: true,
expectedErrString: "CacheSpecValidationFailed",
},
},*/
{
name: "#6: Refresh - Update status to processing",
imageCache: defaultImageCache,
Expand Down
14 changes: 14 additions & 0 deletions deploy/webhook-create-signed-cert.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash

# Copyright 2018 The kube-fledged 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.

set -e

usage() {
Expand Down
14 changes: 14 additions & 0 deletions deploy/webhook-patch-ca-bundle.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash

# Copyright 2018 The kube-fledged 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.

set -o errexit
set -o nounset
set -o pipefail
Expand Down
2 changes: 2 additions & 0 deletions pkg/webhook/imagecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
)

// MutateImageCache modifies image cache resource
/*
func MutateImageCache(ar v1.AdmissionReview) *v1.AdmissionResponse {
glog.V(4).Info("mutating custom resource")
cr := struct {
Expand Down Expand Up @@ -66,6 +67,7 @@ func MutateImageCache(ar v1.AdmissionReview) *v1.AdmissionResponse {
}
return &reviewResponse
}
*/

// ValidateImageCache validates image cache resource
func ValidateImageCache(ar v1.AdmissionReview) *v1.AdmissionResponse {
Expand Down

0 comments on commit db2328c

Please sign in to comment.