Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .pipelines/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,16 @@ stages:
displayName: "Push NPM Image and Wait for Repository"

- script: |
cd ./output
mkdir -p ./output/bins
cd ./output/linux_amd64
sudo find . -mindepth 2 -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete
sudo find . -mindepth 2 -type f -print -exec mv {} . \;
sudo find . -mindepth 2 -type f -print -exec mv {} ../bins \;
sudo rm -R -- */ && cd ..
cd ./windows_amd64
sudo find . -mindepth 2 -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete
sudo find . -mindepth 2 -type f -print -exec mv {} ../bins \;
sudo rm -R -- */ && cd ..
rmdir ./linux_amd64 && rmdir ./windows_amd64
workingDirectory: "$(modulePath)"
name: "PrepareArtifacts"
displayName: "Prepare Artifacts"
Expand Down Expand Up @@ -195,7 +201,7 @@ stages:
inlineScript: |
echo Creating storage container with name acn-$(EnvironmentalVariables.StorageID) and account name $(STORAGE_ACCOUNT_NAME)
az storage container create -n acn-$(EnvironmentalVariables.StorageID) --account-name $(STORAGE_ACCOUNT_NAME) --public-access container
az storage blob upload-batch -d acn-$(EnvironmentalVariables.StorageID) -s ./output/ --account-name $(STORAGE_ACCOUNT_NAME)
az storage blob upload-batch -d acn-$(EnvironmentalVariables.StorageID) -s ./output/bins/ --account-name $(STORAGE_ACCOUNT_NAME)
workingDirectory: "$(modulePath)"
displayName: Create artifact storage container
condition: succeeded()
Expand Down
31 changes: 14 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ CNMS_DIR = cnms/service
NPM_DIR = npm/plugin
OUTPUT_DIR = output
BUILD_DIR = $(OUTPUT_DIR)/$(GOOS)_$(GOARCH)
IMAGE_DIR = $(OUTPUT_DIR)/images
CNM_BUILD_DIR = $(BUILD_DIR)/cnm
CNI_BUILD_DIR = $(BUILD_DIR)/cni
ACNCLI_BUILD_DIR = $(BUILD_DIR)/acncli
Expand Down Expand Up @@ -181,7 +182,7 @@ all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns
endif

ifeq ($(GOOS),linux)
all-images: azure-npm-image azure-cns-aks-swift-image
all-images: azure-npm-image azure-cns-image
else
all-images:
@echo "Nothing to build. Skip."
Expand Down Expand Up @@ -306,13 +307,14 @@ publish-azure-vnet-plugin-image:
.PHONY: azure-npm-image
azure-npm-image: azure-npm
ifeq ($(GOOS),linux)
mkdir -p $(IMAGE_DIR)
docker build \
--no-cache \
-f npm/Dockerfile \
-t $(AZURE_NPM_IMAGE):$(VERSION) \
--build-arg NPM_BUILD_DIR=$(NPM_BUILD_DIR) \
.
docker save $(AZURE_NPM_IMAGE):$(VERSION) | gzip -c > $(NPM_BUILD_DIR)/$(NPM_IMAGE_ARCHIVE_NAME)
docker save $(AZURE_NPM_IMAGE):$(VERSION) | gzip -c > $(IMAGE_DIR)/$(NPM_IMAGE_ARCHIVE_NAME)
endif

# Publish the Azure NPM image to a Docker registry
Expand All @@ -330,7 +332,7 @@ ifeq ($(GOOS),linux)
-t $(AZURE_CNMS_IMAGE):$(VERSION) \
--build-arg CNMS_BUILD_DIR=$(CNMS_BUILD_DIR) \
.
docker save $(AZURE_CNMS_IMAGE):$(VERSION) | gzip -c > $(CNMS_BUILD_DIR)/$(CNMS_IMAGE_ARCHIVE_NAME)
docker save $(AZURE_CNMS_IMAGE):$(VERSION) | gzip -c > $(IMAGE_DIR)/$(CNMS_IMAGE_ARCHIVE_NAME)
endif

# Build the Azure vnet telemetry image
Expand All @@ -349,29 +351,20 @@ azure-vnet-telemetry-image: azure-vnet-telemetry
publish-azure-vnet-telemetry-image:
docker push $(AZURE_VNET_TELEMETRY_IMAGE):$(VERSION)

# Build the Azure CNS image.
# Build the Azure CNS image
.PHONY: azure-cns-image
azure-cns-image: azure-cns
azure-cns-image:
ifeq ($(GOOS),linux)
mkdir -p $(IMAGE_DIR)
docker build \
--no-cache \
-f cns/Dockerfile \
-t $(AZURE_CNS_IMAGE):$(VERSION) \
--build-arg CNS_BUILD_ARCHIVE=$(CNS_BUILD_DIR)/$(CNS_IMAGE_ARCHIVE_NAME) \
.
docker save $(AZURE_CNS_IMAGE):$(VERSION) | gzip -c > $(CNS_BUILD_DIR)/$(CNS_IMAGE_ARCHIVE_NAME)
endif

# Build the Azure CNS image for AKS Swift.
.PHONY: azure-cns-aks-swift-image
azure-cns-aks-swift-image:
ifeq ($(GOOS),linux)
docker build \
-f cns/aks.Dockerfile \
-t $(AZURE_CNS_IMAGE):$(VERSION) \
--build-arg VERSION=$(VERSION) \
--build-arg CNS_AI_PATH=$(cnsaipath) \
--build-arg CNS_AI_ID=$(CNS_AI_ID) \
.
docker save $(AZURE_CNS_IMAGE):$(VERSION) | gzip -c > $(IMAGE_DIR)/$(CNS_IMAGE_ARCHIVE_NAME)
endif

# Publish the Azure NPM image to a Docker registry
Expand Down Expand Up @@ -451,6 +444,10 @@ ifeq ($(GOOS),linux)
chown $(BUILD_USER):$(BUILD_USER) $(NPM_BUILD_DIR)/$(NPM_ARCHIVE_NAME)
endif

.PHONY: release
release:
./scripts/semver-release.sh


PRETTYGOTEST := $(shell command -v gotest 2> /dev/null)

Expand Down
44 changes: 30 additions & 14 deletions cns/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
# Use a minimal image as a parent image
FROM ubuntu:20.04
ARG CNS_BUILD_ARCHIVE
# Get a trusted CA cert bundle
FROM alpine:latest as certs
RUN apk --update add ca-certificates

# Install plugin
COPY $CNS_BUILD_ARCHIVE azure-cns.tgz
# Build cns
FROM golang:1.16-alpine AS builder
# Build ars
ARG VERSION
ARG CNS_AI_PATH
ARG CNS_AI_ID

# Update and unzip cns archive
RUN apt-get update && \
apt-get install -y ca-certificates && \
tar -xvzf azure-cns.tgz && \
rm azure-cns.tgz
RUN apt-get upgrade -y
WORKDIR /usr/local/src/cns

EXPOSE 10090
# Copy the source
COPY . .

# Run the cns command by default when the container starts.
ENTRYPOINT ["sh", "-c", "/azure-cns -c tcp://$CNSIpAddress:10090"]
# Build cns
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o /usr/local/bin/azure-cns -ldflags "-X main.version="$VERSION" -X "$CNS_AI_PATH"="$CNS_AI_ID" -s -w " cns/service/*.go

# Build aitelemetry
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o /usr/local/bin/azure-vnet-telemetry -ldflags "-X main.version="$VERSION" -s -w" cni/telemetry/service/*.go

# Copy into final image
FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /usr/local/bin/azure-cns \
/usr/local/bin/azure-cns
COPY --from=builder /usr/local/bin/azure-vnet-telemetry \
/usr/local/bin/azure-vnet-telemetry
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

ENTRYPOINT [ "/usr/local/bin/azure-cns" ]
EXPOSE 10090
34 changes: 0 additions & 34 deletions cns/aks.Dockerfile

This file was deleted.

91 changes: 91 additions & 0 deletions scripts/semver-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

export MAJOR=0
export MINOR=0
export PATCH=0
export FULL_TAG="v0.0.0"

function create_release () {
parse_git_tag

if increment_git_tag
then
FULL_TAG="v${MAJOR}.${MINOR}.${PATCH}"
set_git_tag
else
echo "local git tag unchanged"
fi
}

function get_git_tag () {

return echo "v${MAJOR}${MINOR}${PATCH}"
}

function set_git_tag () {
read -p "Set git tag to $FULL_TAG? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git tag $FULL_TAG
echo "git tag set to $FULL_TAG"

push_git_tag
fi

return
}

function push_git_tag {
remote=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} | cut -f1 -d"/")

read -p "Push git tag to remote $remote? [y/N] " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git push $remote $FULL_TAG
fi
}

function increment_git_tag () {
read -p "Does this release contain incompatible API changes? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
MAJOR=$((MAJOR+1))
MINOR=0
PATCH=0
return
fi

read -p "Does this release contain added functionality that's backwards compatible? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
MINOR=$((MINOR+1))
PATCH=0
return
fi

read -p "Does this release only contain backwards compatible bug fixes [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
PATCH=$((PATCH+1))
return
fi

false
}

function parse_git_tag () {
FULL_TAG=$(git describe --tags --abbrev=0)
echo Current git tag: $FULL_TAG
echo "--------"
tagArr=(${FULL_TAG//./ })
MAJOR=${tagArr[0]:1}
MINOR=${tagArr[1]}
PATCH=${tagArr[2]}
}

create_release