Skip to content

Commit

Permalink
Use ci-container (#303)
Browse files Browse the repository at this point in the history
* fix: use ci container

Signed-off-by: hlts2 <[email protected]>

* fix: refactor

Signed-off-by: hlts2 <[email protected]>

* fix: deleted commentout

Signed-off-by: hlts2 <[email protected]>

---------

Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 authored Aug 2, 2024
1 parent 1cef2a1 commit 3238422
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ on:
jobs:
e2e:
runs-on: ubuntu-latest
container:
image: ghcr.io/vdaas/vald/vald-ci-container:nightly
options: "--add-host host.docker.internal:host-gateway"
steps:
- uses: actions/checkout@v3
- uses: vdaas/vald-client-ci/.github/actions/e2e@main
Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ GRPC_JAVA_VERSION = version/GRPC_JAVA_VERSION
JAVA_LTS_LATEST_VERSTION = version/JAVA_VERSION_LTS_LATEST
JAVA_LTS_STABLE_VERSTION = version/JAVA_VERSION_LTS_STABLE

K3D_MAKEFILE_URL=https://raw.githubusercontent.com/vdaas/vald/main/Makefile.d/k3d.mk
K3D_MAKEFILE=Makefile.d/k3d.mk

PWD := $(eval PWD := $(shell pwd))$(PWD)

PROTO_ROOT = $(VALD_DIR)/apis/proto
Expand Down Expand Up @@ -179,8 +182,7 @@ ci/deps/install:

.PHONY: ci/deps/update
## update deps for CI environment
ci/deps/update:
@echo "Nothing to do"
ci/deps/update: sync/k3d/mk

.PHONY: ci/package/prepare
## prepare for publich
Expand All @@ -204,3 +206,12 @@ version/java:
## Print Gradle version
version/gradle:
@echo $(GRADLE_VERSION)

Makefile.d:
mkdir -p Makefile.d

sync/k3d/mk: Makefile.d
rm -rf $(K3D_MAKEFILE)
curl -fsSLo $(K3D_MAKEFILE) $(K3D_MAKEFILE_URL)

include $(K3D_MAKEFILE)
68 changes: 68 additions & 0 deletions Makefile.d/k3d.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

K3D_CLUSTER_NAME = "vald-cluster"
K3D_COMMAND = k3d
K3D_NODES = 5
K3D_PORT = 6550
K3D_HOST = localhost
K3D_INGRESS_PORT = 8081
K3D_HOST_PID_MODE = true
K3D_OPTIONS = --port $(K3D_INGRESS_PORT):80@loadbalancer

.PHONY: k3d/install
## install K3D
k3d/install: $(BINDIR)/k3d

$(BINDIR)/k3d:
mkdir -p $(BINDIR)
curl -fsSL https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
chmod a+x $(BINDIR)/$(K3D_COMMAND)

.PHONY: k3d/start
## start k3d (kubernetes in docker) cluster
k3d/start:
$(K3D_COMMAND) cluster create $(K3D_CLUSTER_NAME) \
--agents $(K3D_NODES) \
--image docker.io/rancher/k3s:$(K3S_VERSION) \
--host-pid-mode=$(K3D_HOST_PID_MODE) \
--api-port $(K3D_HOST):$(K3D_PORT) \
-v "/lib/modules:/lib/modules" \
$(K3D_OPTIONS)
@make k3d/config

.PHONY: k3d/storage
## storage k3d (kubernetes in docker) cluster
k3d/storage:
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
kubectl get storageclass
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

.PHONY: k3d/config
## config k3d (kubernetes in docker) cluster
k3d/config:
export KUBECONFIG="$(shell $(K3D_COMMAND) kubeconfig merge -o $(TEMP_DIR)/k3d_$(K3D_CLUSTER_NAME)_kubeconfig.yaml $(K3D_CLUSTER_NAME) --kubeconfig-switch-context)"

.PHONY: k3d/restart
## restart k3d (kubernetes in docker) cluster
k3d/restart: \
k3d/delete \
k3d/start

.PHONY: k3d/delete
## stop k3d (kubernetes in docker) cluster
k3d/delete:
-$(K3D_COMMAND) cluster delete $(K3D_CLUSTER_NAME)

0 comments on commit 3238422

Please sign in to comment.