Skip to content

Commit

Permalink
refactor(_run): reuse kustomize across kube and single examples
Browse files Browse the repository at this point in the history
update ingress-nginx image
simplify kind cluster start

refs ovrclk/engineering#381
refs ovrclk/engineering#356
refs ovrclk/engineering#413

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Jul 27, 2022
1 parent 8c5bb3e commit 55c242f
Show file tree
Hide file tree
Showing 89 changed files with 1,944 additions and 938 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GOLANG_VERSION=1.18.3
KIND_VERSION=0.11.1
KINDEST_VERSION=v1.21.1
KIND_VERSION=0.14.0
KINDEST_VERSION=v1.22.2
GORELEASER_VERSION=v1.6.3
GO111MODULE=on
ROOT_DIR=${AP_ROOT}
Expand Down
4 changes: 2 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ export AP_ROOT

dotenv

make cache

PATH_add "$AP_DEVCACHE_NODE_BIN"
PATH_add "$AP_DEVCACHE_BIN"

make cache

PROVIDER_SERVICES=$AP_DEVCACHE_BIN/provider-services
AKASH=$AP_DEVCACHE_BIN/akash

Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/k8s-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .env
- uses: HatsuneMiku3939/direnv-action@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ env.GOLANG_VERSION }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Prepare images
run: make -s -C _run/kube kind-prepare-images
- uses: engineerd/[email protected]
with:
version: "v${{ env.KIND_VERSION }}"
Expand All @@ -29,7 +31,7 @@ jobs:
- name: Docker Status
run: docker ps -a
- name: Setup Ingress K8S
run: make -s -C _run/kube kind-ingress-setup
run: KUSTOMIZE_INSTALLS=akash-operator-inventory make -s -C _run/kube kind-cluster-setup-e2e-ci
- name: k8s-ingress
run: make -s -C _run/kube kind-k8s-ip
- name: Kube Environment
Expand Down
19 changes: 1 addition & 18 deletions .goreleaser-docker.yaml → .goreleaser-docker-amd64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ builds:
main: ./cmd/provider-services
goarch:
- amd64
- arm64
goos:
- linux
flags:
Expand All @@ -17,12 +16,11 @@ builds:
ldflags:
- "{{ .Env.BUILD_VARS }}"
- "{{ .Env.STRIP_FLAGS }}"

dockers:
- dockerfile: Dockerfile
use: buildx
goarch: amd64
goos: linux
goarch: amd64
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
Expand All @@ -34,18 +32,3 @@ dockers:
- --label=org.opencontainers.image.revision={{ .FullCommit }}
image_templates:
- 'ghcr.io/ovrclk/{{ .ProjectName }}:latest-amd64'
- dockerfile: Dockerfile
use: buildx
goarch: arm64
goos: linux
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:
- 'ghcr.io/ovrclk/{{ .ProjectName }}:latest-arm64'
34 changes: 34 additions & 0 deletions .goreleaser-docker-arm64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
env:
- GO111MODULE=on
- DOCKER_CLI_EXPERIMENTAL="enabled"
builds:
- id: provider-services-linux
binary: provider-services
main: ./cmd/provider-services
goarch:
- arm64
goos:
- linux
flags:
- "-mod={{ .Env.MOD }}"
- "-tags={{ .Env.BUILD_TAGS }}"
- -trimpath
ldflags:
- "{{ .Env.BUILD_VARS }}"
- "{{ .Env.STRIP_FLAGS }}"
dockers:
- 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:
- 'ghcr.io/ovrclk/{{ .ProjectName }}:latest-arm64'
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ GO_MOD ?= readonly
BUILD_TAGS ?= osusergo,netgo,static_build
GORELEASER_STRIP_FLAGS ?=

GORELEASER_BUILD_VARS := \
-X github.com/ovrclk/provider-services/version.Name=provider-services \
-X github.com/ovrclk/provider-services/version.AppName=provider-services \
-X github.com/ovrclk/provider-services/version.BuildTags=\"$(BUILD_TAGS)\" \
-X github.com/ovrclk/provider-services/version.Version=$(RELEASE_TAG) \
-X github.com/ovrclk/provider-services/version.Commit=$(GIT_HEAD_COMMIT_LONG)

ldflags = -linkmode=$(GO_LINKMODE) -X github.com/ovrclk/provider-services/version.Name=provider-services \
-X github.com/ovrclk/provider-services/version.AppName=provider-services \
-X github.com/ovrclk/provider-services/version.BuildTags="$(BUILD_TAGS)" \
-X github.com/ovrclk/provider-services/version.Version=$(shell git describe --tags | sed 's/^v//') \
-X github.com/ovrclk/provider-services/version.Commit=$(GIT_HEAD_COMMIT_LONG)

# check for nostrip option
ifeq (,$(findstring nostrip,$(BUILD_OPTIONS)))
ldflags += -s -w
GORELEASER_STRIP_FLAGS += -s -w
endif

ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

Expand Down
12 changes: 5 additions & 7 deletions _docs/kustomize/akash-node/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: akash-services
resources:
- deployment.yaml
- service.yaml
- ingress.yaml
commonLabels:
app: akash-node
akash.network/component: akash-node

namespace: akash-services

configMapGenerator:

- name: akash-boot
files:
- run.sh
Expand Down Expand Up @@ -155,15 +154,14 @@ configMapGenerator:
##
# required files
##
files:
files: []
# - config/genesis.json

secretGenerator:
- name: akash-keys
##
# required files
##
files:
files: []
# - config/node_key.json
# - config/priv_validator_key.json
# - data/priv_validator_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ spec:
matchLabels:
app: akash-hostname-operator
replicas: 1
revisionHistoryLimit: 1
template:
metadata:
labels:
Expand Down Expand Up @@ -60,12 +61,3 @@ spec:
configMapKeyRef:
name: akash-hostname-operator-config
key: event-failure-limit

volumeMounts:
- name: boot
mountPath: /boot
readOnly: true
volumes:
- name: boot
configMap:
name: akash-hostname-operator-boot
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: akash-services
resources:
- deployment.yaml
- service.yaml
- ingress.yaml
- rbac.yaml
- service_account.yaml
- cluster_role.yaml

namespace: akash-services

configMapGenerator:
- name: akash-hostname-operator-boot
files:
- run.sh
- name: akash-provider-config
literals:
- k8s-manifest-ns=lease
Expand Down
64 changes: 64 additions & 0 deletions _docs/kustomize/akash-operator-inventory/cluster_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: inventory-operator
labels:
akash.network: "true"
app.kubernetes.io/name: akash
app.kubernetes.io/instance: inventory
app.kubernetes.io/component: operator
rules:
- apiGroups:
- ''
resources:
- namespaces
- nodes
- pods
- events
- persistentvolumes
- persistentvolumeclaims
verbs:
- get
- list
- watch
- apiGroups:
- ''
resources:
- pods/exec
verbs:
- create
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
- apiGroups:
- ceph.rook.io
resources:
- cephclusters
- cephblockpools
verbs:
- get
- list
- watch
- apiGroups:
- akash.network
resources:
- inventoryrequests
verbs:
- get
- list
- watch
- apiGroups:
- akash.network
resources:
- inventories
verbs:
- create
- patch
- get
- list
- watch
46 changes: 46 additions & 0 deletions _docs/kustomize/akash-operator-inventory/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: inventory-operator
namespace: akash-services
labels:
akash.network: "true"
app.kubernetes.io/name: akash
app.kubernetes.io/instance: inventory
app.kubernetes.io/component: operator
spec:
selector:
matchLabels:
app.kubernetes.io/name: akash
app.kubernetes.io/instance: inventory
app.kubernetes.io/component: operator
replicas: 1
revisionHistoryLimit: 1
template:
metadata:
labels:
app: inventory-operator
app.kubernetes.io/name: akash
app.kubernetes.io/instance: inventory
app.kubernetes.io/component: operator
spec:
serviceAccountName: inventory-operator
containers:
- name: inventory-operator
image: ghcr.io/ovrclk/provider-services
args:
- "provider-services"
- "operator"
- "inventory"
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
ports:
- containerPort: 8080
name: api
protocol: TCP
10 changes: 10 additions & 0 deletions _docs/kustomize/akash-operator-inventory/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: akash-services
resources:
- deployment.yaml
- service.yaml
- rbac.yaml
- service_account.yaml
- cluster_role.yaml
- role-binding.yaml
File renamed without changes.
17 changes: 17 additions & 0 deletions _docs/kustomize/akash-operator-inventory/role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: inventory-operator
labels:
akash.network: "true"
app.kubernetes.io/name: akash
app.kubernetes.io/instance: inventory
app.kubernetes.io/component: operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: inventory-operator
subjects:
- kind: ServiceAccount
name: inventory-operator
namespace: akash-services
21 changes: 21 additions & 0 deletions _docs/kustomize/akash-operator-inventory/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Service
metadata:
labels:
akash.network: "true"
app.kubernetes.io/name: akash
app.kubernetes.io/instance: inventory
app.kubernetes.io/component: operator
name: inventory-operator
namespace: akash-services
spec:
type: ClusterIP
ports:
- name: api
port: 8080
targetPort: api
appProtocol: http
selector:
app.kubernetes.io/name: akash
app.kubernetes.io/instance: inventory
app.kubernetes.io/component: operator
Loading

0 comments on commit 55c242f

Please sign in to comment.