diff --git a/Makefile b/Makefile index 8f2ec095c3..b62c6038b9 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,7 @@ include make/golang.mk include make/image.mk include make/wasm.mk include make/ci.mk +include make/deploy.mk include make/proto.mk # ============================================================================== @@ -165,6 +166,34 @@ wasm.image: wasm.image.push: @$(MAKE) go.wasm.image.push +# ============================================================================== +## deploy: Deploy Layotto to Kubernetes +# ============================================================================== +.PHONY: deploy +deploy: + @$(MAKE) deploy.k8s + +# ============================================================================== +## deploy.standalone: Deploy Layotto to Kubernetes in Standalone Mode +# ============================================================================== +.PHONY: deploy.standalone +deploy.standalone: + @$(MAKE) deploy.k8s.standalone + +# ============================================================================== +## undeploy: Remove Layotto in Kubernetes +# ============================================================================== +.PHONY: undeploy +undeploy: + @$(MAKE) undeploy.k8s + +# ============================================================================== +## undeploy.standalone: Remove Layotto in Kubernetes in Standalone Mode +# ============================================================================== +.PHONY: undeploy.standalone +undeploy.standalone: + @$(MAKE) undeploy.k8s.standalone + # ============================================================================== ## check: Run all go checks of code sources. # ============================================================================== @@ -291,6 +320,9 @@ ARGS: This option is available when using: make build.multiarch/image.multiarch/push.multiarch Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64" Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 + NAMESPACE The namepace to deploy. Default is `default`. + This option is available when using: make deploy/deploy.standalone/undeploy/undeploy.standalone + Example: make deploy NAMESPACE="layotto" endef export USAGE_OPTIONS diff --git a/demo/deploy/k8s/standalone/default_configmap.yaml b/deploy/k8s/standalone/default_configmap.yaml similarity index 100% rename from demo/deploy/k8s/standalone/default_configmap.yaml rename to deploy/k8s/standalone/default_configmap.yaml diff --git a/demo/deploy/k8s/standalone/default_deployment.yaml b/deploy/k8s/standalone/default_deployment.yaml similarity index 100% rename from demo/deploy/k8s/standalone/default_deployment.yaml rename to deploy/k8s/standalone/default_deployment.yaml diff --git a/demo/deploy/k8s/standalone/default_quickstart.yaml b/deploy/k8s/standalone/default_quickstart.yaml similarity index 100% rename from demo/deploy/k8s/standalone/default_quickstart.yaml rename to deploy/k8s/standalone/default_quickstart.yaml diff --git a/make/common.mk b/make/common.mk index 95f9179e4a..c33725c728 100644 --- a/make/common.mk +++ b/make/common.mk @@ -51,6 +51,12 @@ endif ifeq ($(origin SUPERVISOR_DIR),undefined) SUPERVISOR_DIR := $(ROOT_DIR)/etc/supervisor endif +ifeq ($(origin DEPLOY_DIR),undefined) +DEPLOY_DIR := $(ROOT_DIR)/deploy +endif +ifeq ($(origin K8S_DIR),undefined) +K8S_DIR := $(DEPLOY_DIR)/k8s +endif # set the version number. you should not need to do this # for the majority of scenarios. diff --git a/make/deploy.mk b/make/deploy.mk new file mode 100644 index 0000000000..bd2069b8dc --- /dev/null +++ b/make/deploy.mk @@ -0,0 +1,33 @@ +# Copyright 2021 Layotto Authors +# 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 + +# http://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. + +# This file contains commands to deploy/undeploy layotto into Kubernetes +# Default namespace is `default` + +NAMESPACE := default + +.PHONY: deploy.k8s +deploy.k8s: deploy.k8s.standalone + +.PHONY: deploy.k8s.standalone +deploy.k8s.standalone: + @echo "===========> Deploy Layotto to Kubernetes in namespace ${NAMESPACE} in standalone mode" + @kubectl apply -f $(K8S_DIR)/standalone/default_quickstart.yaml -n ${NAMESPACE} + +.PHONY: undeploy.k8s +undeploy.k8s: undeploy.k8s.standalone + +.PHONY: undeploy.k8s.standalone +undeploy.k8s.standalone: + @echo "===========> Clean Layotto to Kubernetes in namespace ${NAMESPACE} in standalone mode" + @kubectl delete -f $(K8S_DIR)/standalone/default_quickstart.yaml -n ${NAMESPACE}