diff --git a/Makefile b/Makefile index c12a139..f3d1e61 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,10 @@ run-backend: fmt vet ## Run the api backend server. ##@ Build .PHONY: build -build: manifests generate fmt vet ## Build manager binary. +build: build-ui build-go ## Build the UI extension and the ephemeral-access binary. + +.PHONY: build-go +build-go: manifests generate fmt vet ## Build the ephemeral-access binary. go build -o bin/ephemeral-access cmd/main.go # If you wish to build the manager image targeting other platforms you can use the --platform flag. @@ -127,6 +130,15 @@ docker-build: ## Build docker image. docker-push: ## Push docker image. $(CONTAINER_TOOL) push ${IMG} +.PHONY: clean-ui +clean-ui: ## delete the extension.tar file. + find ${UI_DIR} -type f -name extension.tar -delete + +.PHONY: build-ui +build-ui: clean-ui ## build the Argo CD UI extension creating the ui/extension.tar file. + yarn --cwd ${UI_DIR} install + yarn --cwd ${UI_DIR} build + .PHONY: goreleaser-build-local goreleaser-build-local: goreleaser ## Run goreleaser build locally. Use to validate the goreleaser configuration. $(GORELEASER) build --snapshot --clean --single-target --verbose @@ -148,15 +160,8 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform - $(CONTAINER_TOOL) buildx rm argocd-ephemeral-access-builder rm Dockerfile.cross -.PHONY: build-installer -build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment. - mkdir -p dist - cd config/default && $(KUSTOMIZE) edit set image argoproj-labs/argocd-ephemeral-access=${IMG} - $(KUSTOMIZE) build config/default > dist/install.yaml - .PHONY: manifests-release manifests-release: generate manifests kustomize ## Generate the consolidated install.yaml with the release tag. - mkdir -p dist ./scripts/manifests-release.sh $(KUSTOMIZE) $(IMAGE_TAG) ##@ Deployment @@ -175,7 +180,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified .PHONY: deploy deploy: manifests-release ## Deploy distribution to the K8s cluster specified in ~/.kube/config. - $(KUBECTL) apply -f dist/install.yaml + $(KUBECTL) apply -f install.yaml .PHONY: undeploy undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. @@ -247,15 +252,6 @@ $(GOREMAN): $(LOCALBIN) generate-mocks: mockery ## Generate the mocks for the project as configured in .mockery.yaml $(MOCKERY) -.PHONY: clean-ui -clean-ui: - find ${UI_DIR} -type f -name extension.tar -delete - -.PHONY: build-ui -build-ui: clean-ui - yarn --cwd ${UI_DIR} install - yarn --cwd ${UI_DIR} build - # go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist # $1 - target path with name of binary (ideally with version) # $2 - package url which can be installed diff --git a/README.md b/README.md index 445c25e..52dad97 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,81 @@ # argocd-ephemeral-access -A kubernetes controller to manage Argo CD temporary access +## Overview + +This project is an Argo CD extension to allow ephemeral access in Argo +CD UI. It can be viewed as something similar to the functionality that +`sudo` command provides as users can execute actions that require +higher permissions. + +## How it Works + +## Installing + +We provide a consolidated `install.yaml` asset file in every release. +Check the latest release in the [releases page][1] and replace the +`DESIRED_VERSION` in the command below. + +```bash +kubectl apply -f https://github.com/argoproj-labs/argocd-ephemeral-access/releases/download//install.yaml +``` + +This command will create a new namespace `argocd-ephemeral-access` and +deploy the necessary resources. + +## Usage + +## Contributing ### Development -Build the image locally +All necessary development tasks are available as `make targets`. Some +of the targets will make use of external tools. All external tools +used by this project will be automatically downloaded in the `bin` +folder of this repo as required. + +#### Building + +For building all component of this project simply run `make` (which is +an alias for `make build`). This target will: +- Build the Go project. The binary will be placed in the `bin` folder + of this repo. +- Build the UI extension. The UI extension will be packaged in the + `ui/extension.tar` file in this repo. + +There are specific targets that can be used to build each component: + +```bash +make build-go # for building the Go project only +make build-ui # for building the UI extension only +``` + +To build a docker image run one of the following commands: + +```bash +make docker-build +make docker-buildx +``` + +To build a docker image with custom namespace and tag run ```bash IMAGE_NAMESPACE="my.company.com/argoproj-labs" IMAGE_TAG="$(git rev-parse --abbrev-ref HEAD)" make docker-build ``` +#### Running + +```bash +make run +``` + +#### Deploying + Install in kubernetes cluster ```bash -IMAGE_NAMESPACE="my.company.com/argoproj-labs" IMAGE_TAG="$(git rev-parse --abbrev-ref HEAD)" make deploy-local +IMAGE_NAMESPACE="my.company.com/argoproj-labs" IMAGE_TAG="$(git rev-parse --abbrev-ref HEAD)" make deploy ``` + +#### Releasing + +[1]: https://github.com/argoproj-labs/argocd-ephemeral-access/releases diff --git a/scripts/manifests-release.sh b/scripts/manifests-release.sh index 76946d9..767df47 100755 --- a/scripts/manifests-release.sh +++ b/scripts/manifests-release.sh @@ -16,9 +16,10 @@ if [ -z "$IMAGE_TAG" ]; then exit 1 fi -IMAGE_QUAY="quay.io/argoprojlabs/argocd-ephemeral-access:$IMAGE_TAG" +IMAGE_NAMESPACE="${IMAGE_NAMESPACE:-quay.io/argoprojlabs/argocd-ephemeral-access}" +IMAGE_FQN="$IMAGE_NAMESPACE:$IMAGE_TAG" $KUSTOMIZE version -cd ${SRCROOT}/config/default && $KUSTOMIZE edit set image argoproj-labs/argocd-ephemeral-access=${IMAGE_QUAY} +cd ${SRCROOT}/config/default && $KUSTOMIZE edit set image argoproj-labs/argocd-ephemeral-access=${IMAGE_FQN} echo "${AUTOGENMSG}" > "${SRCROOT}/install.yaml" $KUSTOMIZE build "${SRCROOT}/config/default" >> "${SRCROOT}/install.yaml"