Skip to content

Commit

Permalink
feat:license deploy (#4002)
Browse files Browse the repository at this point in the history
Signed-off-by: jingyang <3161362058@qq.com>
  • Loading branch information
zjy365 committed Sep 27, 2023
1 parent 18fef2e commit bff3b03
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
5 changes: 4 additions & 1 deletion frontend/providers/license/deploy/Kubefile
Expand Up @@ -6,6 +6,9 @@ COPY registry registry
COPY manifests manifests

ENV cloudDomain="127.0.0.1.nip.io"
ENV licensePuchaseDomain="cloud.sealos.io"
ENV certSecretName="wildcard-cert"
ENV MONGODB_URI=""
ENV PASSWORD_SALT=""

CMD ["kubectl apply -f manifests"]
CMD ["kubectl apply -f manifests"]
5 changes: 4 additions & 1 deletion frontend/providers/license/deploy/manifests/appcr.yaml.tmpl
Expand Up @@ -11,7 +11,10 @@ spec:
menuData:
helpDropDown: false
nameColor: text-black
name: license
i18n:
zh:
name: 许可证
name: License
type: iframe
displayType: normal

16 changes: 9 additions & 7 deletions frontend/providers/license/deploy/manifests/deploy.yaml.tmpl
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: license-frontend-config
namespace: sealos
namespace: license-frontend
data:
config.yaml: |-
addr: :3000
Expand All @@ -11,7 +11,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: license-frontend
namespace: sealos
namespace: license-frontend
spec:
replicas: 1
selector:
Expand All @@ -32,16 +32,18 @@ spec:
env:
- name: SEALOS_DOMAIN
value: {{ .cloudDomain }}
- name: LICENSE_DOMAIN
value: {{ .licensePuchaseDomain }}
- name: MONGODB_URI
valueFrom:
secretKeyRef:
key: mongodb_uri
name: license-frontend-secret
key: mongodb_uri
- name: PASSWORD_SALT
valueFrom:
secretKeyRef:
key: password_salt
name: license-frontend-secret
key: password_salt
securityContext:
runAsNonRoot: true
runAsUser: 1001
Expand All @@ -57,7 +59,7 @@ spec:
cpu: 10m
memory: 128Mi
# do not modify this image, it is used for CI/CD
image: zhujingyang/sealos-license-frontend:1.0.1
image: ghcr.io/labring/sealos-license-frontend:latest
imagePullPolicy: Always
volumeMounts:
- name: license-frontend-volume
Expand All @@ -74,12 +76,12 @@ metadata:
labels:
app: license-frontend
name: license-frontend
namespace: sealos
namespace: license-frontend
spec:
ports:
- name: http
port: 3000
protocol: TCP
targetPort: 3000
selector:
app: license-frontend
app: license-frontend
8 changes: 8 additions & 0 deletions frontend/providers/license/deploy/manifests/env.yaml.tmpl
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: license-frontend-secret
namespace: license-frontend
stringData:
mongodb_uri: {{ .MONGODB_URI }}
password_salt: {{ .PASSWORD_SALT }}
Expand Up @@ -14,7 +14,7 @@ metadata:
add_header Cache-Control "public";
}
name: license-frontend
namespace: sealos
namespace: license-frontend
spec:
rules:
- host: license.{{ .cloudDomain }}
Expand Down
4 changes: 3 additions & 1 deletion frontend/providers/license/src/pages/api/platform/getEnv.ts
Expand Up @@ -6,13 +6,15 @@ import type { NextApiRequest, NextApiResponse } from 'next';
export type Response = {
domain?: string;
hid: string; // PASSWORD_SALT
LICENSE_DOMAIN: string;
};

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
jsonRes<Response>(res, {
data: {
domain: process.env.SEALOS_DOMAIN || 'cloud.sealos.io',
hid: hashCrypto(process.env.PASSWORD_SALT || '')
hid: hashCrypto(process.env.PASSWORD_SALT || ''),
LICENSE_DOMAIN: process.env.LICENSE_DOMAIN || 'cloud.sealos.io'
}
});
}
4 changes: 2 additions & 2 deletions frontend/providers/license/src/pages/index.tsx
Expand Up @@ -39,15 +39,15 @@ export default function LicenseApp() {

useQuery(['getPlatformEnv'], () => getPlatformEnv(), {
onSuccess(data) {
const hid = data?.hid;
const hid = data.hid;
if (!hid) {
return toast({
title: 'env hid error',
status: 'error'
});
}
const encodedHid = encodeURIComponent(hid);
const main = data?.domain ? data.domain : 'cloud.sealos.io';
const main = data.LICENSE_DOMAIN;
const link = `https:/${main}/license?hid=${encodedHid}`;
setPurchaseLink(link);
}
Expand Down

0 comments on commit bff3b03

Please sign in to comment.