Skip to content

Commit

Permalink
Rework/rename Makefile targets. Bake in image namespace/tag set durin…
Browse files Browse the repository at this point in the history
…g build, as part of argo install
  • Loading branch information
jessesuen committed Dec 1, 2017
1 parent 3f13f5c commit 0ab2688
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 40 deletions.
32 changes: 31 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,37 @@ Go to https://groups.google.com/forum/#!forum/argoproj

## How to setup your dev environment

xxx
### Requirements
* Golang 1.9
* Docker
* dep
* Mac Install: `brew install dep`
* Mac/Linux Install: `go get -u github.com/golang/dep/cmd/dep`

### Quickstart
```
$ go get github.com/argoproj/argo
$ cd $(go env GOPATH)/src/github.com/argoproj/argo
$ dep ensure -vendor-only
$ make
```

### Build workflow-controller and executor images
The following will build the workflow-controller and executor images tagged with the `latest` tag, then push to a personal dockerhub repository:
```
$ make controller-image executor-image IMAGE_TAG=latest IMAGE_NAMESPACE=jessesuen DOCKER_PUSH=true
```

### Build argo cli
```
$ make cli
$ ./dist/argo version
```

### Deploying controller with alternative controller/executor images
```
$ argo install --controller-image jessesuen/workflow-controller:latest --executor-image jessesuen/argoexec:latest
```

## Most needed contributions

Expand Down
55 changes: 27 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ VERSION=$(shell cat ${BUILD_DIR}/VERSION)
REVISION=$(shell git rev-parse HEAD)
REVISION_SHORT=$(shell git rev-parse --short=7 HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)

LDFLAGS = -ldflags "-X ${PACKAGE}.Version=${VERSION} -X ${PACKAGE}.Revision=${REVISION} -X ${PACKAGE}.Branch=${BRANCH}"
TAG=$(shell git describe --exact-match --tags HEAD 2>/dev/null)

BUILDER_IMAGE=argo-builder
BUILDER_CMD=docker run --rm \
Expand All @@ -21,7 +20,14 @@ BUILDER_CMD=docker run --rm \

# docker image publishing options
DOCKER_PUSH=false
IMAGE_TAG=${VERSION}-${REVISION_SHORT}
IMAGE_TAG=${VERSION}

LDFLAGS = -ldflags "-X ${PACKAGE}.Version=${VERSION} \
-X ${PACKAGE}.Revision=${REVISION} \
-X ${PACKAGE}.Branch=${BRANCH} \
-X ${PACKAGE}.Tag=${TAG} \
-X ${PACKAGE}.ImageNamespace=${IMAGE_NAMESPACE} \
-X ${PACKAGE}.ImageTag=${IMAGE_TAG}"

ifeq (${DOCKER_PUSH},true)
ifndef IMAGE_NAMESPACE
Expand All @@ -34,7 +40,7 @@ IMAGE_PREFIX=${IMAGE_NAMESPACE}/
endif

# Build the project
all: cli-linux cli-darwin workflow-image argoexec-image
all: cli controller-image executor-image

builder:
docker build -t ${BUILDER_IMAGE} -f Dockerfile-builder .
Expand All @@ -48,36 +54,29 @@ cli-linux: builder
mkdir -p ${DIST_DIR}/argocli/linux-amd64
mv ${DIST_DIR}/argo ${DIST_DIR}/argocli/linux-amd64/argo

cli-darwin:
GOOS=darwin GOARCH=${GOARCH} go build -v ${LDFLAGS} -o ${DIST_DIR}/argocli/${GOOS}-${GOARCH}/argo ./cmd/argo

apiserver:
go build -v -i ${LDFLAGS} -o ${DIST_DIR}/argo-apiserver ./cmd/argo-apiserver

apiserver-linux: builder
${BUILDER_CMD} make apiserver

apiserver-image: apiserver-linux
docker build -t $(IMAGE_PREFIX)workflow-controller:$(IMAGE_TAG) -f Dockerfile-workflow-controller .
if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)workflow-controller:$(IMAGE_TAG) ; fi
cli-darwin: builder
rm -f ${DIST_DIR}/argocli/darwin-amd64/argo
${BUILDER_CMD} make cli GOOS=darwin
mkdir -p ${DIST_DIR}/argocli/darwin-amd64
mv ${DIST_DIR}/argo ${DIST_DIR}/argocli/darwin-amd64/argo

workflow:
controller:
go build -v -i ${LDFLAGS} -o ${DIST_DIR}/workflow-controller ./cmd/workflow-controller

workflow-linux: builder
${BUILDER_CMD} make workflow
controller-linux: builder
${BUILDER_CMD} make controller

workflow-image: workflow-linux
controller-image: controller-linux
docker build -t $(IMAGE_PREFIX)workflow-controller:$(IMAGE_TAG) -f Dockerfile-workflow-controller .
if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)workflow-controller:$(IMAGE_TAG) ; fi

argoexec:
executor:
go build -i ${LDFLAGS} -o ${DIST_DIR}/argoexec ./cmd/argoexec

argoexec-linux: builder
${BUILDER_CMD} make argoexec
executor-linux: builder
${BUILDER_CMD} make executor

argoexec-image: argoexec-linux
executor-image: executor-linux
docker build -t $(IMAGE_PREFIX)argoexec:$(IMAGE_TAG) -f Dockerfile-argoexec .
if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argoexec:$(IMAGE_TAG) ; fi

Expand All @@ -94,7 +93,7 @@ clean:

.PHONY: builder \
cli cli-linux cli-darwin \
workflow workflow-linux workflow-image \
apiserver apiserver-linux apiserver-image \
argoexec argoexec-linux argoexec-image \
lint test fmt clean
controller controller-linux controller-image \
executor executor-linux executor-image \
lint
# test fmt clean
2 changes: 1 addition & 1 deletion cmd/argo/commands/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func init() {

var lintCmd = &cobra.Command{
Use: "lint (DIRECTORY | FILE1 FILE2 FILE3...)",
Short: "lint a directory containing Workflow YAML files, or a list of multiple Workflow YAML files",
Short: "lint a directory or specific workflow YAML files",
Run: lintYAML,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var uninstallArgs uninstallFlags

var uninstallCmd = &cobra.Command{
Use: "uninstall",
Short: "uninstall workflow-controller and Workflow CRD",
Short: "uninstall controller and CRD",
Run: uninstall,
}

Expand Down
8 changes: 8 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ var (
ShortRevision = Revision[0:7]
FullVersion = fmt.Sprintf("%s-%s", Version, ShortRevision)
DisplayVersion = fmt.Sprintf("%s (Build Date: %s)", FullVersion, BuildDate)
ImageNamespace = ""
ImageTag = Version
)

func init() {
if ImageNamespace == "" {
ImageNamespace = "argoproj"
}
}
17 changes: 9 additions & 8 deletions workflow/common/common.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package common

import (
"github.com/argoproj/argo"
wfv1 "github.com/argoproj/argo/api/workflow/v1"
)

var (
// TODO: replace 'latest' tag with argo.Version when close to release
DefaultControllerImage = "argoproj/workflow-controller:latest"
DefaultExecutorImage = "argoproj/argoexec:latest"
// DefaultWorkflowControllerDeploymentName is the default deployment name of the workflow controller
DefaultControllerDeploymentName = "workflow-controller"
// DefaultControllerNamespace is the default location where the workflow controller is installed
DefaultControllerNamespace = "kube-system"
DefaultControllerImage = argo.ImageNamespace + "/workflow-controller:" + argo.ImageTag
DefaultExecutorImage = argo.ImageNamespace + "/argoexec:" + argo.ImageTag
)

const (
// DefaultControllerDeploymentName is the default deployment name of the workflow controller
DefaultControllerDeploymentName = "workflow-controller"
// DefaultControllerNamespace is the default namespace where the workflow controller is installed
DefaultControllerNamespace = "kube-system"

// WorkflowControllerConfigMapKey is the key in the configmap to retrieve workflow configuration from.
// Content encoding is expected to be YAML.
WorkflowControllerConfigMapKey = "config"
Expand All @@ -31,7 +32,7 @@ const (
PodMetadataAnnotationsVolumePath = "annotations"
// PodMetadataMountPath is the directory mount location for DownwardAPI volume containing pod metadata
PodMetadataMountPath = "/argo/" + PodMetadataVolumeName
// PodMetadataAnnotationsPath is the file path containing pod metadata annotations. Examined by argoexec
// PodMetadataAnnotationsPath is the file path containing pod metadata annotations. Examined by executor
PodMetadataAnnotationsPath = PodMetadataMountPath + "/" + PodMetadataAnnotationsVolumePath

// DockerLibVolumeName is the volume name for the /var/lib/docker host path volume
Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/workflowpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// Reusable k8s pod spec portions used in workflow pods
var (
// volumePodMetadata makes available the pod metadata available as a file
// to the argoexec init and sidekick containers. Specifically, the template
// to the executor's init and sidekick containers. Specifically, the template
// of the pod is stored as an annotation
volumePodMetadata = apiv1.Volume{
Name: common.PodMetadataVolumeName,
Expand Down

0 comments on commit 0ab2688

Please sign in to comment.