Skip to content

Commit

Permalink
add cronjob app to cloud. (labring#4201)
Browse files Browse the repository at this point in the history
Signed-off-by: yy <[email protected]>
  • Loading branch information
lingdie authored Oct 30, 2023
1 parent 961d01a commit 97bd672
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 13 deletions.
2 changes: 2 additions & 0 deletions deploy/cloud/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ retryPullImage ghcr.io/labring/sealos-cloud-dbprovider-frontend:latest
retryPullImage ghcr.io/labring/sealos-cloud-costcenter-frontend:latest
retryPullImage ghcr.io/labring/sealos-cloud-template-frontend:latest
retryPullImage ghcr.io/labring/sealos-cloud-license-frontend:latest
retryPullImage ghcr.io/labring/sealos-cloud-cronjob-frontend:latest

retryPullImage ghcr.io/labring/sealos-cloud-database-service:latest
retryPullImage ghcr.io/labring/sealos-cloud-job-init-controller:latest
Expand All @@ -56,6 +57,7 @@ sealos save -o tars/frontend-costcenter.tar ghcr.io/labring/sealos-cloud-costcen
sealos save -o tars/frontend-applaunchpad.tar ghcr.io/labring/sealos-cloud-applaunchpad-frontend:latest
sealos save -o tars/frontend-template.tar ghcr.io/labring/sealos-cloud-template-frontend:latest
sealos save -o tars/frontend-license.tar ghcr.io/labring/sealos-cloud-license-frontend:latest
sealos save -o tars/frontend-cronjob.tar ghcr.io/labring/sealos-cloud-cronjob-frontend:latest

sealos save -o tars/database-service.tar ghcr.io/labring/sealos-cloud-database-service:latest
sealos save -o tars/job-init.tar ghcr.io/labring/sealos-cloud-job-init-controller:latest
25 changes: 16 additions & 9 deletions deploy/cloud/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,56 +120,63 @@ function sealos_run_frontend {
echo "run desktop frontend"
sealos run tars/frontend-desktop.tar \
--env cloudDomain=$cloudDomain \
--env cloudPort=$cloudPort \
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert" \
--env passwordEnabled="true" \
--config-file etc/sealos/desktop-config.yaml

echo "run applaunchpad frontend"
sealos run tars/frontend-applaunchpad.tar \
--env cloudDomain=$cloudDomain \
--env cloudPort=$cloudPort \
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert"

echo "run terminal frontend"
sealos run tars/frontend-terminal.tar \
--env cloudDomain=$cloudDomain \
--env cloudPort=$cloudPort \
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert"

echo "run dbprovider frontend"
sealos run tars/frontend-dbprovider.tar \
--env cloudDomain=$cloudDomain \
--env cloudPort=$cloudPort \
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert"

echo "run cost center frontend"
sealos run tars/frontend-costcenter.tar \
--env cloudDomain=$cloudDomain \
--env cloudPort=$cloudPort \
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert" \
--env transferEnabled="true" \
--env rechargeEnabled="false"

echo "run template frontend"
sealos run tars/frontend-template.tar \
--env cloudDomain=$cloudDomain \
--env cloudPort=$cloudPort \
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert"

echo "run license frontend"
sealos run tars/frontend-license.tar \
--env cloudDomain=$cloudDomain \
--env cloudPort=$cloudPort \
--env certSecretName="wildcard-cert"
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert" \
--env licensePurchaseDomain="license.sealos.io"

echo "run cronjob frontend"
sealos run tars/frontend-cronjob.tar \
--env cloudDomain=$cloudDomain \
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert"


echo "run db monitoring"
sealos run tars/database-service.tar
}

function resource_exists {
kubectl get $1 >/dev/null 2>&1
kubectl get "$1" >/dev/null 2>&1
}


Expand Down
4 changes: 2 additions & 2 deletions frontend/providers/cronjob/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SERVICE_NAME=sealos-db-provider
SERVICE_NAME=sealos-cronjob
# Image URL to use all building/pushing image targets
IMG ?= $(SERVICE_NAME):latest

Expand Down Expand Up @@ -34,4 +34,4 @@ run: ## Run a dev service from host.

.PHONY: docker-build
docker-build: ## Build docker image with the desktop-frontend.
docker build -t sealos-db-provider:latest . --network host --build-arg HTTP_PROXY=http://127.0.0.1:7890 --build-arg HTTPS_PROXY=http://127.0.0.1:7890
docker build -t sealos-cronjob:latest . --network host --build-arg HTTP_PROXY=http://127.0.0.1:7890 --build-arg HTTPS_PROXY=http://127.0.0.1:7890
1 change: 1 addition & 0 deletions frontend/providers/cronjob/deploy/Kubefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ COPY registry registry
COPY manifests manifests

ENV cloudDomain="127.0.0.1.nip.io"
ENV cloudPort=""
ENV certSecretName="wildcard-cert"

CMD ["kubectl apply -f manifests"]
22 changes: 21 additions & 1 deletion frontend/providers/cronjob/deploy/manifests/ingress.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
# Copyright © 2023 sealos.
#
# 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.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, DELETE, PATCH, OPTIONS"
nginx.ingress.kubernetes.io/cors-allow-origin: "https://{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }}, https://*.{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }}"
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
nginx.ingress.kubernetes.io/cors-max-age: "600"
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
nginx.ingress.kubernetes.io/configuration-snippet: |
more_clear_headers "X-Frame-Options:";
more_set_headers "Content-Security-Policy: default-src * blob: data: *.{{ .cloudDomain }} {{ .cloudDomain }}; img-src * data: blob: resource: *.{{ .cloudDomain }} {{ .cloudDomain }}; connect-src * wss: blob: resource:; style-src 'self' 'unsafe-inline' blob: *.{{ .cloudDomain }} {{ .cloudDomain }} resource:; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: *.{{ .cloudDomain }} {{ .cloudDomain }} resource: *.baidu.com *.bdstatic.com; frame-src 'self' {{ .cloudDomain }} mailto: tel: weixin: mtt: *.baidu.com; frame-ancestors 'self' https://{{ .cloudDomain }} https://*.{{ .cloudDomain }}";
more_set_headers "Content-Security-Policy: default-src * blob: data: *.{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} {{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }}; img-src * data: blob: resource: *.{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} {{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }}; connect-src * wss: blob: resource:; style-src 'self' 'unsafe-inline' blob: *.{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} {{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} resource:; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: *.{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} {{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} resource: *.baidu.com *.bdstatic.com https://js.stripe.com; frame-src 'self' *.{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} {{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} mailto: tel: weixin: mtt: *.baidu.com https://js.stripe.com; frame-ancestors 'self' https://{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }} https://*.{{ .cloudDomain }}{{ if .cloudPort }}:{{ .cloudPort }}{{ end }}";
more_set_headers "X-Xss-Protection: 1; mode=block";

if ($request_uri ~* \.(js|css|gif|jpe?g|png)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ spec:
tls:
- hosts:
- license.{{ .cloudDomain }}
secretName: wildcard-cert
secretName: {{ .certSecretName }}

0 comments on commit 97bd672

Please sign in to comment.