Skip to content

Commit

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

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

* feat: add gitkeep

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

* fix: commit k3d file

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

* fix: deleted gitkeep

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

* fix: add command deps

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

---------

Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 authored Aug 2, 2024
1 parent 219ef72 commit 67c98ee
Show file tree
Hide file tree
Showing 4 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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/vald-origin

wordvecs1000.json
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ VALD_VERSION = VALD_VERSION
VALD_DIR = vald-origin
VALD_CHECKOUT_REF ?= main

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

ROOTDIR = $(eval ROOTDIR := $(shell git rev-parse --show-toplevel))$(ROOTDIR)
GO_VERSION := $(eval GO_VERSION := $(shell cat GO_VERSION))$(GO_VERSION)
TEST_DATASET_PATH = wordvecs1000.json
Expand Down Expand Up @@ -137,7 +140,7 @@ ci/deps/install:

.PHONY: ci/deps/update
## update deps for CI environment
ci/deps/update: mod
ci/deps/update: mod sync/k3d/mk

.PHONY: ci/package/prepare
## prepare for publich
Expand All @@ -160,3 +163,12 @@ mod:
## print go version
version/go:
@echo $(GO_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 67c98ee

Please sign in to comment.