From 8513b6b16a2b3c0d89c40f8d88899fb28a9ffed2 Mon Sep 17 00:00:00 2001 From: jitender Date: Wed, 20 May 2020 14:15:59 +0800 Subject: [PATCH 01/22] added desktop web chart, releases and jenkins --- Jenkinsfile | 69 ++++++++++ charts/nynja-app-desktop/.helmignore | 21 ++++ charts/nynja-app-desktop/Chart.yaml | 5 + .../nynja-app-desktop/templates/00-label.yaml | 32 +++++ .../nynja-app-desktop/templates/_helpers.tpl | 32 +++++ .../templates/configmap.yaml | 20 +++ .../templates/deployment.yaml | 88 +++++++++++++ .../templates/mqtt-serviceentry.yaml | 20 +++ .../templates/nginx-configmap.yaml | 119 ++++++++++++++++++ .../templates/sealedsecrets.yaml | 14 +++ .../nynja-app-desktop/templates/service.yaml | 18 +++ .../templates/virtualservice.yaml | 63 ++++++++++ charts/nynja-app-desktop/values.yaml | 45 +++++++ releases/prod/nynja-app-desktop.yaml | 34 +++++ releases/staging/nynja-app-desktop.yaml | 34 +++++ 15 files changed, 614 insertions(+) create mode 100644 charts/nynja-app-desktop/.helmignore create mode 100644 charts/nynja-app-desktop/Chart.yaml create mode 100644 charts/nynja-app-desktop/templates/00-label.yaml create mode 100644 charts/nynja-app-desktop/templates/_helpers.tpl create mode 100644 charts/nynja-app-desktop/templates/configmap.yaml create mode 100644 charts/nynja-app-desktop/templates/deployment.yaml create mode 100644 charts/nynja-app-desktop/templates/mqtt-serviceentry.yaml create mode 100644 charts/nynja-app-desktop/templates/nginx-configmap.yaml create mode 100644 charts/nynja-app-desktop/templates/sealedsecrets.yaml create mode 100644 charts/nynja-app-desktop/templates/service.yaml create mode 100644 charts/nynja-app-desktop/templates/virtualservice.yaml create mode 100644 charts/nynja-app-desktop/values.yaml create mode 100644 releases/prod/nynja-app-desktop.yaml create mode 100644 releases/staging/nynja-app-desktop.yaml diff --git a/Jenkinsfile b/Jenkinsfile index 20d12358d..26fab97c6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,13 @@ pipeline { IMAGE_BUILD_TAG = "$BRANCH_NAME-$BUILD_NUMBER" HELM_CHART_NAME = "nynja-app-web" DEV_BRANCH = "dev" + SLACK_CHANNEL_DESKTOP = "#nynja-app-desktop" + NAMESPACE_DESKTOP = "nynja-desktop" + APP_NAME_DESKTOP = "nynja-app-desktop" + IMAGE_NAME_DESKTOP = "eu.gcr.io/nynja-ci-201610/${NAMESPACE_DESKTOP}/${APP_NAME_DESKTOP}" + IMAGE_BUILD_TAG_DESKTOP = "$BRANCH_NAME-$BUILD_NUMBER" + HELM_CHART_NAME_DESKTOP = "nynja-app-desktop" + DESKTOP_BRANCH = "desktop-master" } agent { kubernetes(builders.multi([ @@ -158,6 +165,68 @@ pipeline { } } } + } + stage('Build Desktop Release') { + when { + branch env.DESKTOP_BRANCH + } + stages { + stage("Build") { + steps { + container('nodejs') { + sh 'npm install' + sh 'npm run build:prod' + dockerBuildAndPushToRegistry "${NAMESPACE_DESKTOP}/${APP_NAME_DESKTOP}", [IMAGE_BUILD_TAG_DESKTOP] + } + } + } + stage("Helm chart") { + steps { + container('helm') { + helmBuildAndPushToRegistry HELM_CHART_NAME_DESKTOP + } + } + } + stage("Approval: Deploy to staging ?") { + steps { + slackSend channel: SLACK_CHANNEL_DESKTOP, message: "$APP_NAME_DESKTOP: build #$BUILD_NUMBER ready to deploy to `STAGING`, approval required: $BUILD_URL (24h)" + + timeout(time: 24, unit: 'HOURS') { input 'Deploy to staging ?' } + } + post { failure { echo 'Deploy aborted for build #...' }} + } + stage("Deploy to staging") { + steps { + slackSend channel: SLACK_CHANNEL_DESKTOP, message: "$APP_NAME_DESKTOP: deploying build #$BUILD_NUMBER to `STAGING`" + deployHelmTo "staging", NAMESPACE_DESKTOP + } + } + stage("Approval: Deploy to production ?") { + steps { + slackSend channel: SLACK_CHANNEL_DESKTOP, message: "$APP_NAME_DESKTOP: build #$BUILD_NUMBER ready to deploy to `PRODUCTION`, approval required: $BUILD_URL (24h)" + + timeout(time: 7, unit: 'DAYS') { input 'Deploy to production ?' } + } + post { failure { echo 'Deploy aborted for build #...' }} + } + /* + stage('Tagging release') { + steps { + container('nodejs') { + // Updating the "latest tag" + dockerTagLatestAndPushToRegistry "${NAMESPACE_DESKTOP}/${APP_NAME_DESKTOP}", IMAGE_BUILD_TAG_DESKTOP + } + } + } + */ + stage("Deploy to production") { + steps { + slackSend channel: SLACK_CHANNEL_DESKTOP, message: "$APP_NAME_DESKTOP: deploying build #$BUILD_NUMBER to `PRODUCTION`" + + deployHelmTo "prod", NAMESPACE_DESKTOP + } + } + } } } } diff --git a/charts/nynja-app-desktop/.helmignore b/charts/nynja-app-desktop/.helmignore new file mode 100644 index 000000000..daebc7da7 --- /dev/null +++ b/charts/nynja-app-desktop/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/charts/nynja-app-desktop/Chart.yaml b/charts/nynja-app-desktop/Chart.yaml new file mode 100644 index 000000000..2ab9a6f44 --- /dev/null +++ b/charts/nynja-app-desktop/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: Deployment of the nynja desktop application +name: nynja-app-desktop +version: 0.2.4 diff --git a/charts/nynja-app-desktop/templates/00-label.yaml b/charts/nynja-app-desktop/templates/00-label.yaml new file mode 100644 index 000000000..5df61418c --- /dev/null +++ b/charts/nynja-app-desktop/templates/00-label.yaml @@ -0,0 +1,32 @@ +# This hook depends on helm creating the target namespace if it doesn't exist +# before the hook is called. This is the case on Helm v2.9.1 +apiVersion: batch/v1 +kind: Job +metadata: + name: enable-istio-injection-{{ .Release.Namespace }} + namespace: kube-system + labels: + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + app.kubernetes.io/managed-by: {{.Release.Service | quote }} + app.kubernetes.io/instance: {{.Release.Name | quote }} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" + annotations: + helm.sh/hook: pre-install + helm.sh/hook-delete-policy: hook-before-creation,hook-succeeded +spec: + template: + spec: + containers: + - name: labeler + image: gcr.io/google_containers/hyperkube:v1.9.7 + command: + - kubectl + - label + - --overwrite + - ns + - {{ .Release.Namespace }} + - istio-injection=enabled + restartPolicy: Never + # use tiller service account since it should have permissions to do namespace labeling + serviceAccountName: tiller diff --git a/charts/nynja-app-desktop/templates/_helpers.tpl b/charts/nynja-app-desktop/templates/_helpers.tpl new file mode 100644 index 000000000..ef613ae6d --- /dev/null +++ b/charts/nynja-app-desktop/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "nynja-app-desktop.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "nynja-app-desktop.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "nynja-app-desktop.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/charts/nynja-app-desktop/templates/configmap.yaml b/charts/nynja-app-desktop/templates/configmap.yaml new file mode 100644 index 000000000..4eb7faa2a --- /dev/null +++ b/charts/nynja-app-desktop/templates/configmap.yaml @@ -0,0 +1,20 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ template "nynja-app-desktop.fullname" . }}-well-known-files + labels: + app: {{ template "nynja-app-desktop.name" . }} + chart: {{ template "nynja-app-desktop.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + apple-app-site-association: |- + { + "applinks": { + "apps": [], + "details": [{ + "appID": "{{ .Values.wellKnown.appleAppSiteAssociation.appId }}", + "paths": ["*"] + }] + } + } diff --git a/charts/nynja-app-desktop/templates/deployment.yaml b/charts/nynja-app-desktop/templates/deployment.yaml new file mode 100644 index 000000000..eb9058935 --- /dev/null +++ b/charts/nynja-app-desktop/templates/deployment.yaml @@ -0,0 +1,88 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "nynja-app-desktop.fullname" . }} + labels: + app: {{ template "nynja-app-desktop.name" . }} + chart: {{ template "nynja-app-desktop.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "nynja-app-desktop.name" . }} + release: {{ .Release.Name }} + template: + metadata: + annotations: + sidecar.istio.io/inject: "true" + labels: + app: {{ template "nynja-app-desktop.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: nginx-spa + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + volumeMounts: + - mountPath: /usr/share/nginx/html/.well-known + name: well-known-files + readOnly: true + - mountPath: /etc/nginx/conf.d/default.conf + name: nginx-conf + readOnly: true + subPath: default.conf +{{- if .Values.auth.basic.enabled }} + - mountPath: /usr/share/nginx/html/.htpasswd + name: htpasswd + readOnly: true + subPath: .htpasswd +{{- end }} + readinessProbe: + httpGet: + path: /status + port: http + successThreshold: 1 + failureThreshold: 10 + initialDelaySeconds: 10 + periodSeconds: 3 + timeoutSeconds: 5 + livenessProbe: + httpGet: + path: /status + port: http + successThreshold: 1 + failureThreshold: 10 + initialDelaySeconds: 30 + periodSeconds: 3 + timeoutSeconds: 5 + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + volumes: + - name: well-known-files + configMap: + name: {{ template "nynja-app-desktop.fullname" . }}-well-known-files + - name: nginx-conf + configMap: + name: {{ template "nynja-app-desktop.fullname" . }}-nginx-conf +{{- if .Values.auth.basic.enabled }} + - name: htpasswd + secret: + secretName: {{ template "nynja-app-desktop.fullname" . }}-htpasswd +{{- end }} diff --git a/charts/nynja-app-desktop/templates/mqtt-serviceentry.yaml b/charts/nynja-app-desktop/templates/mqtt-serviceentry.yaml new file mode 100644 index 000000000..a5211af6a --- /dev/null +++ b/charts/nynja-app-desktop/templates/mqtt-serviceentry.yaml @@ -0,0 +1,20 @@ +kind: ServiceEntry +apiVersion: networking.istio.io/v1alpha3 +metadata: + name: {{ template "nynja-app-desktop.fullname" . }} + labels: + app: {{ template "nynja-app-desktop.name" . }} + chart: {{ template "nynja-app-desktop.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + hosts: + - {{ .Values.mqtt.host }} + resolution: DNS + ports: + - number: 8083 + name: mqtt-ws + protocol: HTTP + - number: 8888 + name: http-api + protocol: HTTP diff --git a/charts/nynja-app-desktop/templates/nginx-configmap.yaml b/charts/nynja-app-desktop/templates/nginx-configmap.yaml new file mode 100644 index 000000000..cb1926016 --- /dev/null +++ b/charts/nynja-app-desktop/templates/nginx-configmap.yaml @@ -0,0 +1,119 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ template "nynja-app-desktop.fullname" . }}-nginx-conf + labels: + app: {{ template "nynja-app-desktop.name" . }} + chart: {{ template "nynja-app-desktop.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + default.conf: |- + server { + listen 80; + server_name _; + + #sendfile on; + sendfile off; + sendfile_max_chunk 1m; + + tcp_nopush on; + tcp_nodelay off; + + charset utf-8; + access_log off; + #access_log /var/log/nginx/host.access.log main; + + # GZIP settings + gzip on; + gzip_disable "msie6"; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 5; + gzip_buffers 16 4k; + gzip_min_length 256; + gzip_types + application/javascript + application/x-javascript + application/json + application/xml + application/xml+rss + text/plain + text/css + text/javascript + text/xml + image/jpeg + image/png + image/gif; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri /index.html; + + set $auth_type "Restricted"; + # Handle join links (ex. join.nynja.net/123) + set $join_link 0; + + if ( $host ~ ^join\.(?.+)$ ) { + set $join_link 1; + set $auth_type "off"; + } + if ($request_uri ~ ^/.well-known/.*$ ) { + set $join_link 0; + set $auth_type "off"; + } + if ($join_link = 1) { + return 302 https://web.$domain/join$request_uri; + } + + # {{ if .Values.auth.basic.enabled }} + auth_basic $auth_type; + auth_basic_user_file /usr/share/nginx/html/.htpasswd; + # {{ end }} + } + + location /status { + auth_basic off; + return 200; + } + + # Webpack debug proxy (temporary) + #location /debug { + # proxy_set_header X-Forwarded-For $remote_addr; + # proxy_set_header Host $http_host; + # proxy_pass "http://127.0.0.1:8080"; + #} + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + #error_page 500 502 503 504 /50x.html; + #location = /50x.html { + # root /usr/share/nginx/html; + #} + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + location ~ /\.ht { + deny all; + } + } diff --git a/charts/nynja-app-desktop/templates/sealedsecrets.yaml b/charts/nynja-app-desktop/templates/sealedsecrets.yaml new file mode 100644 index 000000000..4061da596 --- /dev/null +++ b/charts/nynja-app-desktop/templates/sealedsecrets.yaml @@ -0,0 +1,14 @@ +{{- if .Values.auth.basic.enabled -}} +apiVersion: bitnami.com/v1alpha1 +kind: SealedSecret +metadata: + name: {{ template "nynja-app-desktop.fullname" . }}-htpasswd + labels: + app: {{ template "nynja-app-desktop.name" . }} + chart: {{ template "nynja-app-desktop.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + encryptedData: + .htpasswd: {{ .Values.auth.basic.sealedSecret }} +{{- end }} diff --git a/charts/nynja-app-desktop/templates/service.yaml b/charts/nynja-app-desktop/templates/service.yaml new file mode 100644 index 000000000..d1af03416 --- /dev/null +++ b/charts/nynja-app-desktop/templates/service.yaml @@ -0,0 +1,18 @@ +kind: Service +apiVersion: v1 +metadata: + name: {{ template "nynja-app-desktop.fullname" . }} + labels: + app: {{ template "nynja-app-desktop.name" . }} + chart: {{ template "nynja-app-desktop.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selector: + app: {{ template "nynja-app-desktop.name" . }} + release: {{ .Release.Name }} + ports: + - protocol: TCP + port: 9080 + targetPort: 80 + name: http diff --git a/charts/nynja-app-desktop/templates/virtualservice.yaml b/charts/nynja-app-desktop/templates/virtualservice.yaml new file mode 100644 index 000000000..b4a723ab1 --- /dev/null +++ b/charts/nynja-app-desktop/templates/virtualservice.yaml @@ -0,0 +1,63 @@ +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "nynja-app-desktop.fullname" . }} + labels: + app: {{ template "nynja-app-desktop.name" . }} + chart: {{ template "nynja-app-desktop.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + gateways: + {{- range .Values.gateway.selector }} + - {{ . }} + {{- end }} + hosts: + {{- range .Values.gateway.hosts }} + - {{ . }} + {{- end }} + http: + - match: + - uri: + prefix: "/mqtt" + timeout: 60s + route: + - destination: + host: {{ .Values.mqtt.host }} + port: + number: 8083 + websocketUpgrade: true + - match: + - uri: + prefix: /api/v1/ + route: + - destination: + host: {{ .Values.mqtt.host }} + port: + number: 8888 + timeout: 10s + retries: + attempts: 3 + perTryTimeout: 5s + - match: + - uri: + prefix: /web/nynjacoin.nccs.chp.CallHistory + route: + - destination: + host: {{ .Values.confcall.historyService }} + port: + number: 41714 + - match: + - uri: + prefix: "/web/" + timeout: 36000s + route: + - destination: + host: {{ .Values.confcall.service }} + port: + number: 41514 + - route: + - destination: + host: {{ template "nynja-app-desktop.fullname" . }} + port: + number: 9080 diff --git a/charts/nynja-app-desktop/values.yaml b/charts/nynja-app-desktop/values.yaml new file mode 100644 index 000000000..6f3725380 --- /dev/null +++ b/charts/nynja-app-desktop/values.yaml @@ -0,0 +1,45 @@ + +replicaCount: 1 + +auth: + # Whether of not basic auth should be enabled to access the website + basic: + enabled: true + # the .htpasswd file content, sealed for the target environment (cluster + namespace) + sealedSecret: + +image: + repository: eu.gcr.io/nynja-ci-201610/nynja-desktop/nynja-app-desktop + tag: stable + pullPolicy: IfNotPresent + +gateway: + selector: + - api-gateway.default.svc.cluster.local + hosts: + - desktop.nynja.net + +wellKnown: + appleAppSiteAssociation: + appId: + +mqtt: + host: messaging-service.messaging.svc.cluster.local + +confcall: + service: calling-service.callconf.svc.cluster.local + historyService: calling-service-history.callconf.svc.cluster.local + +resources: + limits: + cpu: 100m + memory: 200Mi + requests: + cpu: 50m + memory: 100Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/releases/prod/nynja-app-desktop.yaml b/releases/prod/nynja-app-desktop.yaml new file mode 100644 index 000000000..3c42cf5b5 --- /dev/null +++ b/releases/prod/nynja-app-desktop.yaml @@ -0,0 +1,34 @@ +apiVersion: flux.weave.works/v1beta1 +kind: HelmRelease +metadata: + name: nynja-app-desktop + namespace: nynja-app-desktop +spec: + releaseName: nynja-app-desktop + chart: + repository: https://nynjagroup.jfrog.io/nynjagroup/helm/ + name: nynja-app-desktop + version: 0.2.4 + values: + replicaCount: 3 + auth: + basic: + enabled: false + sealedSecret: "" + image: + repository: ${IMAGE_NAME_DESKTOP} + tag: ${IMAGE_BUILD_TAG_DESKTOP} + gateway: + selector: + - api-gateway.default.svc.cluster.local + hosts: + - desktop.nynja.net + - join.nynja.net + wellKnown: + appleAppSiteAssociation: + appId: 9GKQ5AMF2B.com.nynja.mobile.communicator + mqtt: + host: messaging-service.messaging.svc.cluster.local + confcall: + service: calling-service.callconf.svc.cluster.local + historyService: calling-service-history.callconf.svc.cluster.local diff --git a/releases/staging/nynja-app-desktop.yaml b/releases/staging/nynja-app-desktop.yaml new file mode 100644 index 000000000..eead82ec1 --- /dev/null +++ b/releases/staging/nynja-app-desktop.yaml @@ -0,0 +1,34 @@ +apiVersion: flux.weave.works/v1beta1 +kind: HelmRelease +metadata: + name: nynja-app-desktop + namespace: nynja-app-desktop +spec: + releaseName: nynja-app-desktop + chart: + repository: https://nynjagroup.jfrog.io/nynjagroup/helm/ + name: nynja-app-desktop + version: 0.2.4 + values: + replicaCount: 3 + auth: + basic: + enabled: false + sealedSecret: "" + image: + repository: ${IMAGE_NAME_DESKTOP} + tag: ${IMAGE_BUILD_TAG_DESKTOP} + gateway: + selector: + - api-gateway.default.svc.cluster.local + hosts: + - desktop.staging.nynja.net + - join.staging.nynja.net + wellKnown: + appleAppSiteAssociation: + appId: 9GKQ5AMF2B.com.nynja.rc.mobile.communicator + mqtt: + host: messaging-service.messaging.svc.cluster.local + confcall: + service: calling-service.callconf.svc.cluster.local + historyService: calling-service-history.callconf.svc.cluster.local -- GitLab From 384dd6da69c9c513e3583b379dd773a1c35abb80 Mon Sep 17 00:00:00 2001 From: jitender Date: Wed, 20 May 2020 17:54:37 +0800 Subject: [PATCH 02/22] fixed namespace in desktop web release files --- releases/prod/nynja-app-desktop.yaml | 2 +- releases/staging/nynja-app-desktop.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/releases/prod/nynja-app-desktop.yaml b/releases/prod/nynja-app-desktop.yaml index 3c42cf5b5..6a8362d8d 100644 --- a/releases/prod/nynja-app-desktop.yaml +++ b/releases/prod/nynja-app-desktop.yaml @@ -2,7 +2,7 @@ apiVersion: flux.weave.works/v1beta1 kind: HelmRelease metadata: name: nynja-app-desktop - namespace: nynja-app-desktop + namespace: nynja-desktop spec: releaseName: nynja-app-desktop chart: diff --git a/releases/staging/nynja-app-desktop.yaml b/releases/staging/nynja-app-desktop.yaml index eead82ec1..635298162 100644 --- a/releases/staging/nynja-app-desktop.yaml +++ b/releases/staging/nynja-app-desktop.yaml @@ -2,7 +2,7 @@ apiVersion: flux.weave.works/v1beta1 kind: HelmRelease metadata: name: nynja-app-desktop - namespace: nynja-app-desktop + namespace: nynja-desktop spec: releaseName: nynja-app-desktop chart: -- GitLab From 866b49d52d5be57a8b0188da326c14a0674c9870 Mon Sep 17 00:00:00 2001 From: jitender Date: Wed, 20 May 2020 18:43:43 +0800 Subject: [PATCH 03/22] removed desktop release for prod --- releases/prod/nynja-app-desktop.yaml | 34 ---------------------------- 1 file changed, 34 deletions(-) delete mode 100644 releases/prod/nynja-app-desktop.yaml diff --git a/releases/prod/nynja-app-desktop.yaml b/releases/prod/nynja-app-desktop.yaml deleted file mode 100644 index 6a8362d8d..000000000 --- a/releases/prod/nynja-app-desktop.yaml +++ /dev/null @@ -1,34 +0,0 @@ -apiVersion: flux.weave.works/v1beta1 -kind: HelmRelease -metadata: - name: nynja-app-desktop - namespace: nynja-desktop -spec: - releaseName: nynja-app-desktop - chart: - repository: https://nynjagroup.jfrog.io/nynjagroup/helm/ - name: nynja-app-desktop - version: 0.2.4 - values: - replicaCount: 3 - auth: - basic: - enabled: false - sealedSecret: "" - image: - repository: ${IMAGE_NAME_DESKTOP} - tag: ${IMAGE_BUILD_TAG_DESKTOP} - gateway: - selector: - - api-gateway.default.svc.cluster.local - hosts: - - desktop.nynja.net - - join.nynja.net - wellKnown: - appleAppSiteAssociation: - appId: 9GKQ5AMF2B.com.nynja.mobile.communicator - mqtt: - host: messaging-service.messaging.svc.cluster.local - confcall: - service: calling-service.callconf.svc.cluster.local - historyService: calling-service-history.callconf.svc.cluster.local -- GitLab From 602800db3d9b23c99742b70217047887d2debc85 Mon Sep 17 00:00:00 2001 From: jitender Date: Thu, 21 May 2020 12:54:12 +0800 Subject: [PATCH 04/22] added app version in nginx config --- charts/nynja-app-desktop/Chart.yaml | 2 +- charts/nynja-app-desktop/templates/nginx-configmap.yaml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/charts/nynja-app-desktop/Chart.yaml b/charts/nynja-app-desktop/Chart.yaml index 2ab9a6f44..4297728b9 100644 --- a/charts/nynja-app-desktop/Chart.yaml +++ b/charts/nynja-app-desktop/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: Deployment of the nynja desktop application name: nynja-app-desktop -version: 0.2.4 +version: 0.2.5 diff --git a/charts/nynja-app-desktop/templates/nginx-configmap.yaml b/charts/nynja-app-desktop/templates/nginx-configmap.yaml index cb1926016..ef3fca8c5 100644 --- a/charts/nynja-app-desktop/templates/nginx-configmap.yaml +++ b/charts/nynja-app-desktop/templates/nginx-configmap.yaml @@ -78,6 +78,12 @@ data: return 200; } + location /appversion { + auth_basic off; + default_type application/json; + return 200 '{"status":"success","version":"0.4.0","build":"1589451878"}'; + } + # Webpack debug proxy (temporary) #location /debug { # proxy_set_header X-Forwarded-For $remote_addr; -- GitLab From aa8dfb17d3b8cb4b61daf09ffd330660dbe2b2be Mon Sep 17 00:00:00 2001 From: jitender Date: Thu, 21 May 2020 16:49:28 +0800 Subject: [PATCH 05/22] updated staging release for desktop. --- releases/staging/nynja-app-desktop.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releases/staging/nynja-app-desktop.yaml b/releases/staging/nynja-app-desktop.yaml index 635298162..824cb250e 100644 --- a/releases/staging/nynja-app-desktop.yaml +++ b/releases/staging/nynja-app-desktop.yaml @@ -8,7 +8,7 @@ spec: chart: repository: https://nynjagroup.jfrog.io/nynjagroup/helm/ name: nynja-app-desktop - version: 0.2.4 + version: 0.2.5 values: replicaCount: 3 auth: -- GitLab From 8d8adabb5b57d745c234f07c853e3382ff90b97b Mon Sep 17 00:00:00 2001 From: akashtl Date: Sun, 24 May 2020 12:41:58 +0800 Subject: [PATCH 06/22] single update feature handled --- lib/desktop_updater.js | 148 ++++++++++++++++++++++++++++++++++++++--- src/template.ejs | 5 +- 2 files changed, 141 insertions(+), 12 deletions(-) diff --git a/lib/desktop_updater.js b/lib/desktop_updater.js index 66cc981de..8a2402755 100644 --- a/lib/desktop_updater.js +++ b/lib/desktop_updater.js @@ -3,6 +3,11 @@ console.log(process.versions) var isrequestedCheckForUpdate037 = false; var releaseNotes = {}; + +var appversionObj = {}; +var isBuildUpdate = false; +var isVersionUpdate = false; + ipcRendererUpdateWeb.on('update', function (event, message) { var msgJSON = JSON.parse(message); console.log('[DTU] update event ',message); // // message = {key:'',text:''}; @@ -22,21 +27,39 @@ ipcRendererUpdateWeb.on('update', function (event, message) { console.log('[DTU] update for v0.3.7', 'startDownload') startDownloading() } + } else if(msgJSON.key==='update-check-menu') { + getAppVesrion('update-check-menu'); + // ipcRendererOnUpdateEvent(msgJSON); } else { - + ipcRendererOnUpdateEvent(msgJSON); } -}) +}); function ipcRendererOnUpdateEvent(msgJSON) { - + /** + * msgJSON key's + * key: 'update-check', + * upgrade: true/false, + * upgradeType: 'version' / 'build', + * version: '0.4.0', + * build: 1590208348, + * currentVersion: '0.4.0', + * currentBuild: 1590208348, + * status: 200 + */ switch (msgJSON.key) { case 'update-check-menu': //Update UI button or text document.getElementById('update-info').style = (msgJSON.upgrade ? '' : (msgJSON.version !== '' ? 'display: none;' : 'display: none;')); + document.getElementById('update-info').innerHTML = (msgJSON.upgrade ? 'Update Available' : (msgJSON.version !== '' ? '' : '')); - document.getElementById('update_latest_version').innerHTML = (msgJSON.upgrade ? 'A new release is available (' + msgJSON.version + ').' : (msgJSON.version !== '' ? 'You are using latest version of Nynja.' : 'Encountered an error while updating, try again later.')); - document.getElementById('update_current_version').innerHTML = 'version ' + msgJSON.currentVersion; + + // document.getElementById('update_latest_version').innerHTML = (msgJSON.upgrade ? 'A new release is available (' + msgJSON.version + ').' : (msgJSON.version !== '' ? 'You are using latest version of Nynja.' : 'Encountered an error while updating, try again later.')); + document.getElementById('update_latest_version').innerHTML = (msgJSON.upgrade ? 'A new release is available ' + msgJSON.version + ' (' + msgJSON.build + ').' : (msgJSON.version !== '' ? 'You are using latest version of Nynja.' : 'Encountered an error while updating, try again later.')); + + //document.getElementById('update_current_version').innerHTML = 'current version ' + msgJSON.currentVersion; + document.getElementById('update_current_version').innerHTML = 'current version ' + msgJSON.currentVersion+ ' (' + msgJSON.currentBuild+')'; document.getElementById('update_version_electron').innerHTML = (msgJSON.electron === undefined ? process.versions.electron : msgJSON.electron); document.getElementById('update_version_chromium').innerHTML = (msgJSON.chromium === undefined ? process.versions.chrome : msgJSON.chromium); @@ -58,9 +81,12 @@ function ipcRendererOnUpdateEvent(msgJSON) { //Update UI button or text document.getElementById('update-info').style = (msgJSON.upgrade ? '' : (msgJSON.version !== '' ? 'display: none;' : 'display: none;')); + document.getElementById('update-info').innerHTML = (msgJSON.upgrade ? 'Update Available' : (msgJSON.version !== '' ? '' : '')); - document.getElementById('update_latest_version').innerHTML = (msgJSON.upgrade ? 'A new release is available (' + msgJSON.version + ').' : (msgJSON.version !== '' ? 'You are using latest version of Nynja.' : 'Encountered an error while updating, try again later.')); - document.getElementById('update_current_version').innerHTML = 'version ' + msgJSON.currentVersion; + + document.getElementById('update_latest_version').innerHTML = (msgJSON.upgrade ? 'A new release is available ' + msgJSON.version + ' (' + msgJSON.build + ').' : (msgJSON.version !== '' ? 'You are using latest version of Nynja.' : 'Encountered an error while updating, try again later.')); + + document.getElementById('update_current_version').innerHTML = 'current version ' + msgJSON.currentVersion+ ' (' + msgJSON.currentBuild+')'; //document.getElementById('update_version_electron').innerHTML = msgJSON.electron; //document.getElementById('update_version_chromium').innerHTML = msgJSON.chromium; //document.getElementById('update_version_nodejs').innerHTML = msgJSON.nodejs; @@ -122,6 +148,7 @@ function showReleaseNotes(type, msgJSON) { if(msgJSON.upgrade){ releaseNotesVersions = [msgJSON.version]; console.log('[DTU]', 'msgJSON.upgrade:',msgJSON.upgrade,releaseNotesVersions) + releaseNotes[msgJSON.version].content = msgJSON.notes; }else{ releaseNotesVersions = releaseNotesVersions.slice(releaseNotesVersions.indexOf(msgJSON.currentVersion)); console.log('[DTU]', 'msgJSON.upgrade:',msgJSON.upgrade, releaseNotesVersions) @@ -171,14 +198,28 @@ function updateVersionNotesClick() { * Update Available click handler * Show update popup */ -function updateInfoClick(msgJSON) {//alert(1); +function updateInfoClick(msgJSON) { //show modal popup document.getElementById('update-desc-box').style = ''; - + console.log(msgJSON) if (msgJSON.upgrade) { - // // document.getElementById('update-install').removeEventListener('click'); + // // // document.getElementById('update-install').removeEventListener('click'); document.getElementById('update_download_install').style = ''; document.getElementById('update_download_install').addEventListener("click", updateConfClick) + if(msgJSON.upgradeType==="version"){ + // alert(1) + document.getElementById('update_download_install').innerHTML = 'Update'; + // document.getElementById('update_download_install').style = ''; + // document.getElementById('update_download_install').addEventListener("click", updateConfClick) + document.getElementById('releases_info_p').innerHTML = 'After finishing the download, NYNJA application will be restarted to apply new updates.'; + }else{ + // alert(2) + + document.getElementById('update_download_install').innerHTML = 'Refresh Only'; + // document.getElementById('update_refresh_only').style = ''; + // document.getElementById('update_refresh_only').addEventListener("click", startDownloading) + document.getElementById('releases_info_p').innerHTML = 'By clicking on Confirm button, Nynja application will refresh to apply new updates.'; + } } } @@ -203,7 +244,17 @@ function updateConfClick(msgJSON) {//alert(1); function startDownloading() { console.log('start-download') //Update confirm and notify main process - ipcRendererUpdateWeb.send('update-main', 'update-start'); + if(isVersionUpdate){ + // alert('start1') + appversionObj.action = 'update-start'; + ipcRendererUpdateWeb.send('update-main', appversionObj); + } else if(isBuildUpdate){ + // alert('start2') + appversionObj.action = 'update-build'; + ipcRendererUpdateWeb.send('update-main', appversionObj); + } + + //ipcRendererUpdateWeb.send('update-main', 'update-start'); document.getElementById('update-info').style = 'display: none;'; document.getElementById('update-desc-box').style = 'display: none;'; document.getElementById('update-conf-box').style = 'display: none;'; @@ -422,4 +473,79 @@ if (process.env.currentVersion) { }); +/******************************** Single Update Feature ********************************/ + /** + * Call api to get version(major), build(minor) + * and latest notes for release + */ + getAppVesrion(); + function getAppVesrion(type='update-check'){ + /*fetch('https://desktop.staging.nynja.net/appversion', { + cache: 'no-store', + method: 'GET', + headers: { + 'Cache-Control': 'no-store', + 'Pragma': 'no-cache', + }, + }) + .then(function (res) { + // console.log('[DTU]',res); + console.log('[DTU] appversion api res',res); + return res.json(); + }) + .then(function (data) { + console.log('[DTU] appversion api data',data); + }) + .catch(function(err) { + console.log('[DTU] appversion api err', err); + });*/ + appversionObj = {"status":"success","version":"0.4.0","build":1590208350, "notes":['notes-sample']}; + + console.log('[DTU] current build',process.env.currentBuild); + console.log('[DTU] appversionObj.currentBuild > process.env.currentBuild',(appversionObj.currentBuild > process.env.currentBuild)); + if(process.env.currentBuild){ + if(appversionObj.build > process.env.currentBuild) { + isBuildUpdate = true; + } + } + console.log('[DTU] current version',process.env.currentVersion); + if(process.env.currentVersion){ + var api_version_split = appversionObj.version.split('.'); + var app_env_curr_ver_split = process.env.currentVersion.split('.'); + console.log('[DTU] check version major ',api_version_split[0]>app_env_curr_ver_split[0]); + console.log('[DTU] check version minor ',api_version_split[1]>app_env_curr_ver_split[1]); + console.log('[DTU] check version patch ',api_version_split[2]>app_env_curr_ver_split[2]); + // check major + if(api_version_split[0]>app_env_curr_ver_split[0]){ + isVersionUpdate = true; + }else{ + // check minor + if(api_version_split[1]>app_env_curr_ver_split[1]){ + isVersionUpdate = true; + }else{ + // check patch + if(api_version_split[2]>app_env_curr_ver_split[2]){ + isVersionUpdate = true; + }else{ + + isVersionUpdate = false; + } + } + } + } + console.log('[DTU] isVersionUpdate: ', isVersionUpdate); + console.log('[DTU] isBuildUpdate: ', isBuildUpdate); + + ipcRendererOnUpdateEvent({ + key: type, + upgrade: isVersionUpdate||isBuildUpdate, + upgradeType: (isVersionUpdate?'version':(isBuildUpdate?'build':'')), + version: appversionObj.version, + build: appversionObj.build, + currentVersion: process.env.currentVersion, + currentBuild: process.env.currentBuild, + notes: appversionObj.notes, + status: 200 + }) + } } diff --git a/src/template.ejs b/src/template.ejs index 8065d21d7..2e1a900dc 100644 --- a/src/template.ejs +++ b/src/template.ejs @@ -165,6 +165,9 @@
+ @@ -178,7 +181,7 @@