Skip to content

Commit

Permalink
feat: gpu support
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Apr 17, 2023
1 parent e7aa0b5 commit 2859d54
Show file tree
Hide file tree
Showing 266 changed files with 6,349 additions and 3,240 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GOLANG_VERSION=1.19.2
GOLANG_VERSION=1.20.2
KINDEST_VERSION=v1.24.7
GORELEASER_VERSION=v1.11.4
GO111MODULE=on
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ coverage.txt

go.work
go.work.sum

.devenv
35 changes: 0 additions & 35 deletions .goreleaser-docker-arm64.yaml

This file was deleted.

18 changes: 18 additions & 0 deletions .goreleaser-docker-amd64.yaml → .goreleaser-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ builds:
main: ./cmd/provider-services
goarch:
- amd64
- arm64
goos:
- linux
flags:
Expand All @@ -17,6 +18,8 @@ builds:
ldflags:
- "{{ .Env.BUILD_VARS }}"
- "{{ .Env.STRIP_FLAGS }}"
archives:
- format: binary
dockers:
- dockerfile: Dockerfile
use: buildx
Expand All @@ -33,3 +36,18 @@ dockers:
- --label=org.opencontainers.image.revision={{ .FullCommit }}
image_templates:
- '{{ .Env.DOCKER_IMAGE }}:latest-amd64'
- dockerfile: Dockerfile
use: buildx
goos: linux
goarch: arm64
build_flag_templates:
- --platform=linux/arm64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url={{.GitURL}}
- --label=org.opencontainers.image.source={{.GitURL}}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
image_templates:
- '{{ .Env.DOCKER_IMAGE }}:latest-arm64'
12 changes: 6 additions & 6 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ docker_manifests:

nfpms:
- id: w/version
vendor: "Overclock Labs Inc."
homepage: "https://ovrclk.com"
maintainer: "Overclock Labs Inc. <[email protected]>"
vendor: "Akash Network"
homepage: "https://akash.network"
maintainer: "Akash Network <[email protected]>"
file_name_template: "provider-services_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
formats:
- deb
- rpm
license: Apache 2.0
- id: wo/version
vendor: "Overclock Labs Inc."
homepage: "https://ovrclk.com"
maintainer: "Overclock Labs Inc. <[email protected]>"
vendor: "Akash Network"
homepage: "https://akash.network"
maintainer: "Akash Network <[email protected]>"
file_name_template: "provider-services_{{ .Os }}_{{ .Arch }}"
formats:
- deb
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ DOCKER_RUN := docker run --rm -v $(shell pwd):/workspace -w /workspa
GOLANGCI_LINT_RUN := $(GOLANGCI_LINT) run
LINT = $(GOLANGCI_LINT_RUN) ./... --disable-all --deadline=5m --enable

GORELEASER_CONFIG = .goreleaser.yaml
GORELEASER_CONFIG ?= .goreleaser.yaml

GIT_HEAD_COMMIT_LONG := $(shell git log -1 --format='%H')
GIT_HEAD_COMMIT_SHORT := $(shell git rev-parse --short HEAD)
Expand Down
2 changes: 1 addition & 1 deletion _run/common-commands.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KEY_NAME ?= main
KEY_NAME ?= main

KEY_ADDRESS ?= $(shell $(AKASH) $(KEY_OPTS) keys show "$(KEY_NAME)" -a)
PROVIDER_KEY_NAME ?= provider
Expand Down
146 changes: 8 additions & 138 deletions _run/common-kind.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# image's name in GH Actions.
export KIND_NAME ?= $(shell basename $$PWD)

KIND_CREATE := $(AP_RUN_DIR)/.kind-create

ifeq (, $(KINDEST_VERSION))
$(error "KINDEST_VERSION is not set")
endif

KIND_IMG ?= kindest/node:$(KINDEST_VERSION)

K8S_CONTEXT ?= $(shell kubectl config current-context)
SETUP_KIND := "$(AP_ROOT)/script/setup-kind.sh"
KIND_CONFIG ?= default
KIND_CONFIG_FILE := $(shell "$(SETUP_KIND)" config-file $$PWD $(KIND_CONFIG))

KIND_HTTP_PORT = $(shell docker inspect \
--type container "$(KIND_NAME)-control-plane" \
Expand All @@ -33,38 +33,6 @@ KIND_K8S_IP = $(shell docker inspect \
KIND_PORT_BINDINGS = $(shell docker inspect "$(KIND_NAME)-control-plane" \
--format '{{index .NetworkSettings.Ports "80/tcp" 0 "HostPort"}}' 2> /dev/null)

SETUP_KIND := "$(AP_ROOT)/script/setup-kind.sh"
KIND_CONFIG ?= default
KIND_CONFIG_FILE := $(shell "$(SETUP_KIND)" config-file $$PWD $(KIND_CONFIG))

include ../common-kustomize.mk

# certain targets need to use bash
# detect where bash is installed
# use akash-node-ready target as example
BASH_PATH := $(shell which bash)

INGRESS_CONFIG_PATH ?= ../ingress-nginx.yaml
CALICO_MANIFEST ?= https://docs.projectcalico.org/v3.8/manifests/calico.yaml

ifeq ($(AKASH_SRC_IS_LOCAL), true)
AKASH_DOCKER_IMAGE ?= ghcr.io/akash-network/node:latest-$(UNAME_ARCH)
else
AKASH_DOCKER_IMAGE ?= ghcr.io/akash-network/node:$(AKASH_VERSION)-$(UNAME_ARCH)
endif

DOCKER_IMAGE ?= ghcr.io/akash-network/provider:latest-$(UNAME_ARCH)

PROVIDER_HOSTNAME ?= localhost
PROVIDER_HOST = $(PROVIDER_HOSTNAME):$(KIND_HTTP_PORT)
PROVIDER_ENDPOINT = http://$(PROVIDER_HOST)

METALLB_CONFIG_PATH ?= ../metallb.yaml
METALLB_IP_CONFIG_PATH ?= ../kind-config-metal-lb-ip.yaml
METALLB_SERVICE_PATH ?= ../../_docs/provider/kube/metallb-service.yaml

KIND_ROLLOUT_TIMEOUT ?= 90

.PHONY: app-http-port
app-http-port:
@echo $(KIND_HTTP_PORT)
Expand All @@ -73,112 +41,14 @@ app-http-port:
kind-k8s-ip:
@echo $(KIND_K8S_IP)

.PHONY: kind-prepare-images
kind-prepare-images:
ifneq ($(SKIP_BUILD), true)
make -C $(AP_ROOT) docker-image
ifeq ($(AKASH_SRC_IS_LOCAL), true)
make -C $(AKASH_LOCAL_PATH) docker-image
else
docker pull $(AKASH_DOCKER_IMAGE)
endif
endif

.PHONY: kind-upload-images
kind-upload-images: $(KIND)
ifeq ($(KIND_NAME), single)
$(KIND) --name "$(KIND_NAME)" load docker-image "$(AKASH_DOCKER_IMAGE)"
endif
$(KIND) --name "$(KIND_NAME)" load docker-image "$(DOCKER_IMAGE)"

.PHONY: kind-port-bindings
kind-port-bindings: $(KIND)
@echo $(KIND_PORT_BINDINGS)

.PHONY: kind-cluster-setup
kind-cluster-setup: init \
kind-prepare-images \
kind-cluster-create \
kind-setup-ingress \
kind-upload-images \
kustomize-init \
kustomize-deploy-services \
kind-deployments-rollout \
kind-setup-$(KIND_NAME)

.PHONY: kind-cluster-setup-e2e
kind-cluster-setup-e2e: kind-cluster-create kind-cluster-setup-e2e-ci

.PHONY: kind-cluster-setup-e2e-ci
kind-cluster-setup-e2eci:
kind-cluster-setup-e2e-ci: \
kind-setup-ingress \
kind-upload-images \
kustomize-init \
kustomize-deploy-services \
kind-deployments-rollout

$(KIND_CREATE): $(KIND) $(AP_RUN_DIR)
$(KIND) create cluster --config "$(KIND_CONFIG_FILE)" --name "$(KIND_NAME)" --image "$(KIND_IMG)"
touch $@

.INTERMEDIATE: kind-cluster-create
kind-cluster-create: $(KIND_CREATE)
.INTERMEDIATE: kube-cluster-create-kind
kube-cluster-create-kind: $(KUBE_CREATE)

.PHONY: kind-setup-ingress
kind-setup-ingress: kind-setup-ingress-$(KIND_CONFIG)

.PHONY: kind-setup-ingress-calico
kind-setup-ingress-calico:
kubectl apply -f "$(CALICO_MANIFEST)"
# Calico needs to be managing networking before finishing setup
kubectl apply -f "$(INGRESS_CONFIG_PATH)"
kubectl rollout status deployment -n ingress-nginx ingress-nginx-controller --timeout=$(KIND_ROLLOUT_TIMEOUT)s
kubectl apply -f "$(METALLB_CONFIG_PATH)"
kubectl apply -f "$(METALLB_IP_CONFIG_PATH)"
kubectl apply -f "$(METALLB_SERVICE_PATH)"
"$(SETUP_KIND)" calico-metrics

.PHONY: kind-setup-ingress-default
kind-setup-ingress-default:
kubectl label nodes $(KIND_NAME)-control-plane akash.network/role=ingress
kubectl apply -f "$(INGRESS_CONFIG_PATH)"
kubectl rollout status deployment -n ingress-nginx ingress-nginx-controller --timeout=$(KIND_ROLLOUT_TIMEOUT)s
kubectl apply -f "$(METALLB_CONFIG_PATH)"
kubectl apply -f "$(METALLB_IP_CONFIG_PATH)"
kubectl apply -f "$(METALLB_SERVICE_PATH)"
"$(SETUP_KIND)"

.PHONY: kind-cluster-delete
kind-cluster-delete: $(KIND)
.PHONY: kube-cluster-delete-kind
kube-cluster-delete-kind: $(KIND)
$(KIND) delete cluster --name "$(KIND_NAME)"
rm -rf $(KIND_CREATE)

.PHONY: kind-status-ingress-%
kind-status-ingress-%:
kubectl rollout status -n akash-services ingress $* --timeout=$(KIND_ROLLOUT_TIMEOUT)s

.PHONY: kind-deployment-rollout-%
kind-deployment-rollout-%:
kubectl -n akash-services rollout status deployment $* --timeout=$(KIND_ROLLOUT_TIMEOUT)s
kubectl -n akash-services wait pods -l akash.network/component=$* --for condition=Ready --timeout=$(KIND_ROLLOUT_TIMEOUT)s

.PHONY: akash-node-ready
akash-node-ready: SHELL=$(BASH_PATH)
akash-node-ready:
@( \
max_retry=15; \
counter=0; \
while [[ counter -lt max_retry ]]; do \
read block < <(curl -s $(AKASH_NODE)/status | jq -r '.result.sync_info.latest_block_height' 2> /dev/null); \
if [[ $$? -ne 0 || $$block -lt 1 ]]; then \
echo "unable to get node status. sleep for 1s"; \
((counter++)); \
sleep 1; \
else \
echo "latest block height: $${block}"; \
exit 0; \
fi \
done; \
exit 1 \
)
rm -rf $(KUBE_CREATE)
Loading

0 comments on commit 2859d54

Please sign in to comment.