diff --git a/chart/Chart.yaml b/chart/Chart.yaml index e72f2b3..501b5e7 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: cloudypress description: A helm chart for deploying Wordpress on Cloudyne Hosting type: application -version: 0.1.0 +version: 0.1.5 appVersion: "6.1.1" diff --git a/chart/templates/certificate.yaml b/chart/templates/certificate.yaml index f42645a..a4ba8a8 100644 --- a/chart/templates/certificate.yaml +++ b/chart/templates/certificate.yaml @@ -10,5 +10,13 @@ spec: kind: ClusterIssuer secretName: {{ include "..fullname" . }}-cert-secret commonName: {{ .Values.site.url }} - dnsNames: {{ range .Values.site.ingressNames }} - - {{ . }}{{end}} + dnsNames: + - {{ .Values.site.url | replace "www." "" }} + - www.{{ .Values.site.url | replace "www." "" }} + - {{ .Values.site.url | replace "www." "" | replace "." "-" }}.eu.cust.azurecd.net + - www.{{ .Values.site.url | replace "www." "" | replace "." "-" }}.eu.cust.azurecd.net + {{- if .Values.site.additionalIngressNames }} + {{- range .Values.site.additionalIngressNames }} + - {{ . }} + {{- end }} + {{- end }} \ No newline at end of file diff --git a/chart/templates/configmap.yaml b/chart/templates/configmap.yaml index 21b773e..eeefec5 100644 --- a/chart/templates/configmap.yaml +++ b/chart/templates/configmap.yaml @@ -13,18 +13,18 @@ data: WP_HOME: {{ .Values.site.url }} WP_SITEURL: {{ .Values.site.url }}/wp - {{- if and .values.Site.init .Values.site.init.composerPackage }} + {{- if and .Values.site.init .Values.site.init.composerPackage }} RUN_COMPOSER: "true" INSTALL_SITE: {{ .Values.site.init.composerPackage }} SET_THEME: {{ .Values.site.init.themeName | default "" }} {{- end }} - {{- if and .values.Site.init .Values.site.init.content .Values.site.init.content.import }} + {{- if and .Values.site.init .Values.site.init.content .Values.site.init.content.import }} RUN_IMPORTS: "true" IMPORT_CONTENT: {{ .Values.site.init.content.url }} {{- end }} - {{- if and .values.Site.init .Values.site.init.database .Values.site.init.database.import }} + {{- if and .Values.site.init .Values.site.init.database .Values.site.init.database.import }} RUN_DATABASEIMPORTS: "true" IMPORT_DATABASE: {{ .Values.site.init.database.url }} FORCE_IMPORT_DB: {{ .Values.site.init.database.force | default "false" }} @@ -34,7 +34,7 @@ data: kind: ConfigMap apiVersion: v1 metadata: - name: {{ include "..fullname" . }}-configfiles + name: {{ include "..fullname" . }}-cfg labels: {{- include "..labels" . | nindent 8 }} data: diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index f48a206..0e0a59f 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -1,63 +1,111 @@ apiVersion: apps/v1 -kind: Certificate +kind: Deployment metadata: - name: {{ include "..fullname" . }}-cert - labels: - {{- include "..labels" . | nindent 8 }} - cloudyne.systems/component: site + name: {{ include "..fullname" . }}-cert + labels: + {{- include "..labels" . | nindent 4 }} + cloudyne.systems/component: site spec: - {{- if and .Values.customer .Values.customer.package }} - replicas: {{ .Values.customer.package.replicas | default 1 }} - {{- end }} - selector: - matchLabels: - cloudyne.systems/customer: {{ .Values.customer.name }} - cloudyne.systems/site: {{ .Values.site.url }} - template: - metadata: - labels: - cloudyne.systems/customer: {{ .Values.customer.name }} - cloudyne.systems/site: {{ .Values.site.url }} - spec: - securityContext: - fsGroup: 65534 - volumes: - - name: cloud - persistentVolumeClaim: - claimName: pvc-{{ include "..fullname" . }} - - name: local - emptyDir: {} - initContainers: - - name: deploy - securityContext: - allowPrivilegeEscalation: false - runAsUser: 0 - {{- if .Values.global }} - image: {{ .Values.global.initImage }}:{{ .Values.global.imagetag }} - {{- else }} - image: ghcr.io/cloudynes/php-init:latest - {{- end }} - imagePullPolicy: Always - command: [ "bash", "/init-py/init.sh" ] - volumeMounts: - - name: site - mountPath: /app - {{- if and .Values.site .Values.site.storage .Values.site.storage.cloud .Values.site.storage.cloud.folders }} - {{- range $v := .Values.site.storage.cloud.folders }} - - name: cloud - mountPath: {{ $v.localPath }} - subPath: {{ $v.cloudPath }} - {{- end }} - {{- end }} - envFrom: - - configMapRef: - name: {{ include "..fullname" . }}-env - - secretRef: - name: {{ include "..fullname" . }}-db-auth - containers: - - name: wordpress - securityContext: - runAsUser: 65534 - - +{{- if and .Values.customer .Values.customer.package }} + replicas: {{ .Values.customer.package.replicas | default 1 }} +{{- else }} + replicas: 1 +{{- end }} + selector: + matchLabels: + cloudyne.systems/customer: {{ .Values.customer.name }} + cloudyne.systems/site: {{ .Values.site.url }} + template: + metadata: + labels: + cloudyne.systems/customer: {{ .Values.customer.name }} + cloudyne.systems/site: {{ .Values.site.url }} + spec: + securityContext: + fsGroup: 65534 + volumes: + - name: cloud + persistentVolumeClaim: + claimName: pvc-{{ include "..fullname" . }} + - name: local + emptyDir: {} + - name: serverconfig + configMap: + name: {{ include "..fullname" . }}-cfg + initContainers: + - name: deploy + securityContext: + allowPrivilegeEscalation: false + runAsUser: 0 + {{- if .Values.global }} + image: {{ .Values.global.initImage | default "ghcr.io/cloudynes/php-init" }}:{{ .Values.global.imagetag | default "latest" }} + {{- else }} + image: ghcr.io/cloudynes/php-init:latest + {{- end }} + imagePullPolicy: Always + volumeMounts: + - name: site + mountPath: /app + {{- if and .Values.site .Values.site.storage .Values.site.storage.cloud .Values.site.storage.cloud.folders }} + {{- range $v := .Values.site.storage.cloud.folders }} + - name: cloud + mountPath: {{ $v.localPath }} + subPath: {{ $v.cloudPath }} + {{- end }} + {{- end }} + envFrom: + - configMapRef: + name: {{ include "..fullname" . }}-env + - secretRef: + name: {{ include "..fullname" . }}-db-auth + containers: + - name: wordpress + securityContext: + runAsUser: 65534 + {{- if .Values.global }} + image: {{ .Values.global.initImage | default "ghcr.io/cloudynes/php-nginx" }}:{{ .Values.global.imagetag | default "latest" }} + {{- else }} + image: ghcr.io/cloudynes/php-nginx:latest + {{- end }} + imagePullPolicy: Always + volumeMounts: + - name: site + mountPath: /app + - name: serverconfig + mountPath: /etx/nginx/nginx.conf + subPath: nginx.conf + - name: serverconfig + mountPath: /usr/local/etc/php-fpm.d/www.conf + {{- if and .Values.site .Values.site.storage .Values.site.storage.cloud .Values.site.storage.cloud.folders }} + {{- range $v := .Values.site.storage.cloud.folders }} + - name: cloud + mountPath: {{ $v.localPath }} + subPath: {{ $v.cloudPath }} + {{- end }} + {{- end }} + envFrom: + - configMapRef: + name: {{ include "..fullname" . }}-env + - secretRef: + name: {{ include "..fullname" . }}-db-auth + resources: + {{- if and .Values.customer .Values.customer.package .Values.customer.package.cpu }} + requests: + cpu: {{ .Values.customer.package.cpu.avg | default "1000m" }} + memory: {{ .Values.customer.package.mem.avg | default "1Gi" }} + limits: + cpu: {{ .Values.customer.package.cpu.peak | default "1000m" }} + memory: {{ .Values.customer.package.mem.peak | default "1Gi" }} + {{- else }} + requests: + cpu: 1000m + memory: 1Gi + limits: + cpu: 1000m + memory: 1Gi + {{- end }} + ports: + - containerPort: 8080 + name: http + protocol: TCP \ No newline at end of file diff --git a/chart/templates/ingress.yaml b/chart/templates/ingress.yaml new file mode 100644 index 0000000..f11d0e2 --- /dev/null +++ b/chart/templates/ingress.yaml @@ -0,0 +1,76 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "..fullname" . }} + labels: + {{- include "..labels" . | nindent 4 }} +spec: + ingressClassName: nginx + tls: + - secretName: {{ include "..fullname" . }}-cert-secret + hosts: + - {{ .Values.site.url | replace "www." "" }} + - www.{{ .Values.site.url | replace "www." "" }} + - {{ .Values.site.url | replace "www." "" | replace "." "-" }}.eu.cust.azurecd.net + - www.{{ .Values.site.url | replace "www." "" | replace "." "-" }}.eu.cust.azurecd.net + {{- if .Values.site.additionalIngressNames }} + {{- range .Values.site.additionalIngressNames }} + - {{ . }} + {{- end }} + {{- end }} + + rules: + - host: {{ .Values.site.url | replace "www." "" }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "..fullname" . }} + port: + number: 80 + - host: www.{{ .Values.site.url | replace "www." "" }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "..fullname" . }} + port: + number: 80 + - host: {{ .Values.site.url | replace "www." "" | replace "." "-" }}.eu.cust.azurecd.net + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "..fullname" . }} + port: + number: 80 + - host: www.{{ .Values.site.url | replace "www." "" | replace "." "-" }}.eu.cust.azurecd.net + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "..fullname" . }} + port: + number: 80 + {{- if .Values.site.additionalIngressNames }} + {{- range .Values.site.additionalIngressNames }} + - host: {{ . }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "..fullname" . }} + port: + number: 80 + {{- end }} + {{- end }} \ No newline at end of file diff --git a/chart/templates/resourcequota.yaml b/chart/templates/resourcequota.yaml index e631370..29c66aa 100644 --- a/chart/templates/resourcequota.yaml +++ b/chart/templates/resourcequota.yaml @@ -6,7 +6,19 @@ metadata: {{- include "..labels" . | nindent 4 }} spec: hard: - requests.cpu: {{ .Values.customer.package.cpu.avg }} - limits.cpu: {{ .Values.customer.package.cpu.peak }} - requests.memory: {{ .Values.customer.package.mem.avg }} - limits.memory: {{ .Values.customer.package.mem.peak }} + {{- if and .Values.customer .Values.customer.package }} + {{- if .Values.customer.package.cpu }} + requests.cpu: {{ .Values.customer.package.cpu.avg | default "1000m" }} + limits.cpu: {{ .Values.customer.package.cpu.peak | default "1500m"}} + {{- else }} + requests.cpu: 1000m + limits.cpu: 1500m + {{- end }} + {{- if .Values.customer.package.mem }} + requests.memory: {{ .Values.customer.package.mem.avg | default "512Mi" }} + limits.memory: {{ .Values.customer.package.mem.peak | default "1Gi" }} + {{- else }} + requests.memory: 512Mi + limits.memory: 1Gi + {{- end }} + {{- end }} \ No newline at end of file diff --git a/chart/templates/service.yaml b/chart/templates/service.yaml new file mode 100644 index 0000000..f99242f --- /dev/null +++ b/chart/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "..fullname" . }}-cert + labels: + {{- include "..labels" . | nindent 8 }} + cloudyne.systems/component: site +spec: + ports: + - name: http + port: 80 + targetPort: 8080 + selector: + cloudyne.systems/customer: {{ .Values.customer.name }} + cloudyne.systems/site: {{ .Values.site.url }} + type: ClusterIP diff --git a/chart/values.yaml b/chart/values.yaml index f136080..af30c3f 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -2,80 +2,89 @@ customer: # Customer Name/identifier - name: gunnarnilssonmaskin + name: mycustomer # Timezone for customer timezone: "Europe/Stockholm" # Package/Resource Settings - package: - size: small - replicas: 1 - cpu: - avg: 500m - peak: 1000m - mem: - avg: 512Mi - peak: 1Gi - disk: 5Gi + package: {} + + # Defaults: + # package: + # size: small + # replicas: 1 + # cpu: + # avg: 500m + # peak: 1000m + # mem: + # avg: 512Mi + # peak: 1Gi + # disk: 5Gi # Website Configuration site: # The main URL for the website - url: "www.gunnarnilssonmaskin.se" - - # Settings for the webroot (used by Nginx) - webroot: - path: "/app/web" - indexes: "index.php index.html index.htm" + url: "www.mycustomer.com" # Whether to keep plugins and Wordpress updated autoUpdate: true + # Storage settings + storage: {} + + # Defaults: + # storage: + # cloud: + # class: "premium01" + # type: "Premium_LRS" + # container: "www-mycustomer-com" + # folders: + # - cloudPath: "uploads" + # localPath: "/app/web/app/uploads" + # - cloudyPath: "gallery" + # localPath: "/app/web/app/uploads" + + # Initialization Settings init: # The composer package that contains the site - composerPackage: "buildahome/gunnarnilssonmaskin-se" + composerPackage: "somens/mycustomer-app" # The name of the theme which the composer package refers to - themeName: "gunnarnilssonmaskin-se-theme" + themeName: "mycustomer-app-theme" - # Import content to wp-content directory from zip file - content: - import: true - url: "https://www.gunnarnilssonmaskin.se/gunnar.zip" + # Optional: Import content to wp-content directory from zip file + content: {} + + # content: + # import: true + # url: "https://mycustomer.com/wp-content-data.zip" + + # Optional: Import database from URL + database: {} - # # Import database from URL # database: # import: true # force: false - # url: "https://www.gunnarnilssonmaskin.se/gunnar.sql" + # url: "https://www.mycustomer.com/mysqldump.sql" - # The allowed names for ingress to this site - ingressNames: - - "gunnarnilssonmaskin.se" - - "www.gunnarnilssonmaskin.se" - - "gunnarnilssonmaskin-se.eu.cust.azurecd.net" - - "www-gunnarnilssonmaskin-se.eu.cust.azurecd.net" + # Settings for the webroot (used by Nginx) + webroot: {} + + # Defaults: + # webroot: + # path: "/app/web" + # indexes: "index.php index.html index.htm" - # Storage settings - storage: + # Additional ingress names for the site + # Default ingress names are (customer domain: testsite.com, domain = testsite, tld = com): + # - . + # - www.. + # - -.eu.cust.azurecd.net + # - www--.eu.cust.azurecd.net + additionalIngressNames: [] - # Settings for cloud storage - cloud: - # Storage class to use for the cloud storage - class: "premium01" - type: "Premium_LRS" - - # The container in Azure storage - container: "gunnarnilssonmaskin-se" - - # Folders to map up to the Azure storage - folders: - - cloudPath: "uploads" - localPath: "/app/web/app/uploads" - - cloudyPath: "gallery" - localPath: "/app/web/app/uploads" # Global configuration global: