Skip to content

Commit

Permalink
Extension sync (#80)
Browse files Browse the repository at this point in the history
* bring extension from kubesquash, initial tweaks for connectivity to squashctl

* keep pod alive during Machine mode

* allow vs-code debugging in secure-mode

* add automatic connection to secure-mode

* select demo from interactive prompt

* add workflow helpers to service2 demo

* notes on usage of sample apps

* bring kubesquash makefile and scripts to squash

* migrate makefile and cloudbuild from kubesquash

* cleanup comments, remove kubesquash refs

* correct version in Makefile
  • Loading branch information
mitchdraft committed Feb 19, 2019
1 parent eaa0707 commit a7cb134
Show file tree
Hide file tree
Showing 47 changed files with 4,293 additions and 507 deletions.
174 changes: 68 additions & 106 deletions Makefile
Expand Up @@ -2,126 +2,120 @@ DOCKER_REPO ?= soloio
VERSION ?= $(shell git describe --tags)
DATE = $(shell date '+%Y-%m-%d.%H:%M:%S')
IMAGE_VERSION ?= "v0.1.9" # TODO(mitchdraft) - replace with actual workflow
LDFLAGS := "-X github.com/solo-io/squash/pkg/version.Version=$(VERSION) \
-X github.com/solo-io/squash/pkg/version.Timestamp=$(DATE) \
-X github.com/solo-io/squash/pkg/version.ImageVersion=$(IMAGE_VERSION) \
-X github.com/solo-io/squash/pkg/version.ImageRepo=$(DOCKER_REPO)"

.PHONY: all
all: binaries deployment
all: binaries containers ## (default) Builds binaries and containers

.PHONY: help
help:
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sort | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"

.PHONY: binaries
binaries: target/squash-client/squash-client target/squash
binaries: target/debugger-container/debugger-container target/squashctl # Builds squashctl binaries in and places them in target/ folder

RELEASE_BINARIES := target/squash-client/squash-client target/squash-linux target/squash-osx target/squash-windows
RELEASE_BINARIES := target/squashctl-linux target/squashctl-osx

.PHONY: release-binaries
release-binaries: $(RELEASE_BINARIES)

.PHONY: manifests
manifests: deployment
cp -f target/kubernetes/squash-client.yml ./contrib/kubernetes

.PHONY: upload-release
upload-release: release-binaries manifests dist
./contrib/github-release.sh github_api_token=$(GITHUB_TOKEN) owner=solo-io repo=squash tag=$(VERSION)
@$(foreach BINARY,$(RELEASE_BINARIES),./contrib/upload-github-release-asset.sh github_api_token=$(GITHUB_TOKEN) owner=solo-io repo=squash tag=$(VERSION) filename=$(BINARY);)

.PHONY: containers
containers: target/squash-client-container
containers: target/debugger-container-dlv-container target/debugger-container-gdb-container ## Builds debug containers

.PHONY: prep-containers
prep-containers: target/squash-client/squash-client target/squash-client/Dockerfile
.PHONY: push-containers
push-containers: target/debugger-container-dlv-pushed target/debugger-container-gdb-pushed ## Pushes debug containers to $(DOCKER_REPO)

.PHONY: release
release: push-containers release-binaries ## Pushes containers to $(DOCKER_REPO) and releases binaries to GitHub

.PHONY: upload-release
upload-release: ## Uploads artifacts to GitHub releases
./hack/github-release.sh owner=solo-io repo=squash tag=$(VERSION)
@$(foreach BINARY,$(RELEASE_BINARIES),./hack/upload-github-release-asset.sh owner=solo-io repo=squash tag=$(VERSION) filename=$(BINARY);)

SRCS=$(shell find ./pkg -name "*.go") $(shell find ./cmd -name "*.go")

# Pass in build-time variables
LDFLAGS := "-X github.com/solo-io/squash/pkg/version.Version=$(VERSION) \
-X github.com/solo-io/squash/pkg/version.Timestamp=$(DATE) \
-X github.com/solo-io/squash/pkg/version.ImageVersion=$(IMAGE_VERSION) \
-X github.com/solo-io/squash/pkg/version.ImageRepo=$(DOCKER_REPO)"

target:
[ -d $@ ] || mkdir -p $@

target/squash: target $(SRCS)
go build -o $@ ./cmd/squash-cli

target/squash-linux: target $(SRCS)
GOOS=linux go build -o $@ ./cmd/squash-cli
target/squashctl: target $(SRCS)
go build -ldflags=$(LDFLAGS) -o $@ ./cmd/squashctl

target/squash-osx: target $(SRCS)
GOOS=darwin go build -o $@ ./cmd/squash-cli
target/squashctl-osx: target $(SRCS)
GOOS=darwin go build -ldflags=$(LDFLAGS) -o $@ ./cmd/squashctl

target/squash-windows: target $(SRCS)
GOOS=windows go build -o $@ ./cmd/squash-cli
target/squashctl-linux: target $(SRCS)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -ldflags=$(LDFLAGS) -o $@ ./cmd/squashctl

target/squash-client/: | target
target/squash-client/:
target/debugger-container/:
[ -d $@ ] || mkdir -p $@

target/squash-client/squash-client: | target/squash-client/
target/squash-client/squash-client: $(SRCS)
GOOS=linux CGO_ENABLED=0 go build -ldflags '-w' -o target/squash-client/squash-client ./cmd/squash-client/platforms/kubernetes

target/squash-client/Dockerfile: | target/squash-client/
target/debugger-container/debugger-container: | target/debugger-container/
target/debugger-container/debugger-container: $(SRCS)
GOOS=linux CGO_ENABLED=0 go build -a -tags netgo -ldflags '-w' -o ./target/debugger-container/debugger-container ./cmd/debugger-container/

target/squash-client/Dockerfile: ./cmd/squash-client/platforms/kubernetes/Dockerfile
cp -f ./cmd/squash-client/platforms/kubernetes/Dockerfile ./target/squash-client/Dockerfile

target/squash-client-container: target/squash-client/squash-client target/squash-client/Dockerfile
docker build -t $(DOCKER_REPO)/squash-client:$(VERSION) ./target/squash-client/
target/debugger-container/Dockerfile.dlv: | target/debugger-container/
target/debugger-container/Dockerfile.dlv: cmd/debugger-container/Dockerfile.dlv
cp cmd/debugger-container/Dockerfile.dlv target/debugger-container/Dockerfile.dlv
target/debugger-container-dlv-container: ./target/debugger-container/debugger-container target/debugger-container/Dockerfile.dlv
docker build -f target/debugger-container/Dockerfile.dlv -t $(DOCKER_REPO)/debugger-container-dlv:$(VERSION) ./target/debugger-container/
touch $@

target/squash-client-base-container:
docker build -t $(DOCKER_REPO)/squash-client-base -f cmd/squash-client/platforms/kubernetes/Dockerfile.base cmd/squash-client/platforms/kubernetes/
target/debugger-container-dlv-pushed: target/debugger-container-dlv-container
docker push $(DOCKER_REPO)/debugger-container-dlv:$(VERSION)
touch $@

.PHONY: push-client-base
push-client-base:
docker push $(DOCKER_REPO)/squash-client-base

target/%.yml : contrib/%.yml.tmpl
SQUASH_REPO=$(DOCKER_REPO) SQUASH_VERSION=$(VERSION) go run contrib/templategen.go $< > $@

target/kubernetes/squash-client.yml: target/squash-client-container
target/debugger-container/Dockerfile.gdb: | target/debugger-container/
target/debugger-container/Dockerfile.gdb: cmd/debugger-container/Dockerfile.gdb
cp cmd/debugger-container/Dockerfile.gdb target/debugger-container/Dockerfile.gdb
target/debugger-container-gdb-container: ./target/debugger-container/debugger-container target/debugger-container/Dockerfile.gdb
docker build -f target/debugger-container/Dockerfile.gdb -t $(DOCKER_REPO)/debugger-container-gdb:$(VERSION) ./target/debugger-container/
touch $@
target/debugger-container-gdb-pushed: target/debugger-container-gdb-container
docker push $(DOCKER_REPO)/debugger-container-gdb:$(VERSION)
touch $@

target/kubernetes/:
[ -d $@ ] || mkdir -p $@
.PHONY: publish-extension
publish-extension: bump-extension-version ## (vscode) Publishes extension
./hack/publish-extension.sh

deployment: | target/kubernetes/
deployment: target/kubernetes/squash-client.yml
.PHONY: package-extension
package-extension: bump-extension-version ## (vscode) Packages extension
cd editor/vscode && vsce package

.PHONY: bump-extension-version
bump-extension-version: ## (vscode) Bumps extension version
cd editor/vscode && \
jq '.version="$(VERSION)" | .version=.version[1:]' package.json > package.json.tmp && \
mv package.json.tmp package.json && \
jq '.version="$(VERSION)" | .binaries.linux="$(shell sha256sum target/squashctl-linux|cut -f1 -d" ")" | .binaries.darwin="$(shell sha256sum target/squashctl-osx|cut -f1 -d" ")"' src/squash.json > src/squash.json.tmp && \
mv src/squash.json.tmp src/squash.json

.PHONY: clean
clean:
clean: ## Deletes target folder
rm -rf target

dist: target/squash-client-container
docker push $(DOCKER_REPO)/squash-client:$(VERSION)

# make the solo-kit-provided resources
# do this on initialization and whenever the apichanges
.PHONY: generate-sk
generate-sk: docs-and-code/v1

docs-and-code/v1:
go run cmd/generate-code/main.go
dist: target/debugger-container-gdb-pushed target/debugger-container-dlv-pushed ## Pushes all containers to $(DOCKER_REPO)

# this will be removed when clis merge
.PHONY: tmpkubesquash
tmpkubesquash:
go build -o target/tmpks/tmpks cmd/kubesquash/main.go

.PHONY: tmpagent
tmpagent:
GOOS=linux go build -ldflags=$(LDFLAGS) -o target/agent/squash-agent cmd/agent/main.go

.PHONY: runtest
runtest: tmpagent
cd test/e2e/ && ginkgo -v .

## Temp
DEVVERSION="dev"
.PHONY: devpush
devpush:
docker build -t $(DOCKER_REPO)/squash-agent:$(DEVVERSION) -f cmd/agent/Dockerfile ./target/agent/
docker push $(DOCKER_REPO)/squash-agent:$(DEVVERSION)


# Docs

.PHONY: generatedocs
generatedocs:
go run cmd/generate-docs/main.go
Expand All @@ -130,35 +124,3 @@ generatedocs:
.PHONY: previewsite
previewsite:
cd site && python3 -m http.server 0



####
# squashclt
# builds squashctl for each os (linux and darwin), puts output in the target/ dir
####

.PHONY: squashctl
squashctl: target/squashctl-osx target/squashctl-linux target/kubesquash-container/kubesquash-container
echo "Building all squashctl"

.PHONY: squashctldev
squashctldev: target/squashctl target/kubesquash-container/kubesquash-container
echo "just building for the default OS"

# (convenience only) this one will will build squashctl for the builder's os
target/squashctl: target $(SRCS)
go build -ldflags=$(LDFLAGS) -o $@ ./cmd/squashctl/main.go

target/squashctl-osx: target $(SRCS)
GOOS=darwin go build -ldflags=$(LDFLAGS) -o $@ ./cmd/squashctl/main.go

target/squashctl-linux: target $(SRCS)
GOOS=linux go build -ldflags=$(LDFLAGS) -o $@ ./cmd/squashctl/main.go

target/kubesquash-container/:
[ -d $@ ] || mkdir -p $@

target/kubesquash-container/kubesquash-container: | target/kubesquash-container/
target/kubesquash-container/kubesquash-container: $(SRCS)
GOOS=linux CGO_ENABLED=0 go build -ldflags '-w' -o $@ ./cmd/kubesquash-container/main.go
81 changes: 0 additions & 81 deletions Makefile_kubesquash

This file was deleted.

4 changes: 2 additions & 2 deletions PREVERSION.md
Expand Up @@ -44,7 +44,7 @@
- [ ] (P1) non rbac mode

## Release tasks
- [ ] (P0) update makefile for new client/docker settings
- [x] (P0) update makefile for new client/docker settings
- [ ] (P0) update the docs
- [ ] (P0) no server required
- [x] new cli flags
Expand All @@ -54,7 +54,7 @@
- [ ] (P0) (small) update the tag in `github.com/solo-io/squash/contrib/kubernetes/squash-client.yml`

## Port from kubesquash
- [ ] (P0) there are a few kubesquash commits that were contributed recently that we should port.
- [x] (P0) there are a few kubesquash commits that were contributed recently that we should port.
- [ ] (P0) also port the CI process that releases everything automatically.
- [ ] (P0) port and merge the extensions (i.e. port the download an version pinning from the kube squash extension)

Expand Down
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -19,8 +19,6 @@ Squash is built to be easily extensible, allowing – and encouraging – adding

Squash integration with [Envoy](https://www.envoyproxy.io) is now live! Read about the Squash HTTP filter, now part of upstream Envoy [here](https://www.envoyproxy.io/docs/envoy/latest/configuration/http_filters/squash_filter.html)

**If you're using Kubernetes, you should check out [KubeSquash](https://github.com/solo-io/kubesquash)**

To learn more about the motivation behind project squash, read our blog [post](https://medium.com/solo-io/squash-microservices-debugger-5023e27533de) or [watch](https://www.infoq.com/presentations/squash-microservices-container) session ([slides](https://www.slideshare.net/IditLevine/debugging-microservices-qcon-2017)). We also encourage you to read squash technical overview [blog](https://medium.com/solo-io/technical-introduction-to-squash-399e0c0c54b).

To stay up-to-date with Squash, follow us [@GetSoloIO](https://twitter.com/GetSoloIO) and join us on our [slack channel](http://slack.solo.io).
Expand Down
58 changes: 58 additions & 0 deletions cloudbuild.yaml
@@ -0,0 +1,58 @@
steps:

- name: 'gcr.io/cloud-builders/go'
env:
- VERSION=$TAG_NAME
entrypoint: make
args: ['binaries', 'release-binaries']

- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker login --username soloiobot --password $$DOCKER_HUB_PASSWORD']
secretEnv: ['DOCKER_HUB_PASSWORD']

- name: 'gcr.io/cloud-builders/docker'
env:
- VERSION=$TAG_NAME
entrypoint: make
args: ['containers']

- name: 'gcr.io/$PROJECT_ID/vsce'
env:
- VERSION=$TAG_NAME
entrypoint: make
args: ['bump-extension-version']

- name: node:10.10.0
entrypoint: npm
args: ['install']
dir: ./extension/vscode

- name: 'gcr.io/$PROJECT_ID/vsce'
args: ['package']
dir: ./extension/vscode
# publish
- name: 'gcr.io/cloud-builders/docker'
env:
- VERSION=$TAG_NAME
entrypoint: make
args: ['push-containers']

- name: 'gcr.io/$PROJECT_ID/go-make'
env:
- VERSION=$TAG_NAME
entrypoint: make
args: ['upload-release']
secretEnv: ['GITHUB_TOKEN']

# TODO(mitchdraft) enable vscode publish
#- name: 'gcr.io/$PROJECT_ID/vsce'
# entrypoint: ./hack/publish-extension.sh
# secretEnv: ['VSCODE_TOKEN']

secrets:
- kmsKeyName: projects/solo-public/locations/global/keyRings/build/cryptoKeys/build-key
secretEnv:
GITHUB_TOKEN: CiQABlzmSRpjt9c2jcCGU2lIk68qAkHIzIHUeYS+artlcens/7oSUQCCPGSG407g5usGvAhM+oL98Xir0fHWUiNe3827h9zdhmkCbrZpNqfVFkMhAxQ/ZlhC31+KwzWoHnDSb3RN7CoKj+gves6q7MMf7wNxSmC46A==
DOCKER_HUB_PASSWORD: CiQABlzmSW0u+qhXDvTCxLnbi09Zm88eCU0wSdvFn1W+6WOpTgQSTgCCPGSGTAlMndrEkYOynPhDzTXrW1q1eAsQYjKOWOwZKodcQZ2WIzdvpOOjv+WrGTssWWg1uPFV4CnajT7DzeNAb7USkla1epatm6OnuQ==
VSCODE_TOKEN: CiQABlzmSepRzBG6r2UapqKVaJfx5X3PQgWpuKtIinDWI4IpZsASXQCCPGSGtYjgB1ARs6VcRy3J23Mlbo7zeqPamti48qk71axnOBu4pSomCTKj+4iB81E/dgJEmo9aXOIfPoSv7jEs1ijN7J326jA+AOS1M4eUQwfAWovUtmjecP0p+Q==

0 comments on commit a7cb134

Please sign in to comment.