diff --git a/package-examples/ghost/Kptfile b/package-examples/ghost/Kptfile new file mode 100644 index 0000000000..bd5de11bd2 --- /dev/null +++ b/package-examples/ghost/Kptfile @@ -0,0 +1,12 @@ +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: ghost + annotations: + config.kubernetes.io/local-config: "true" +info: + description: sample description +pipeline: + mutators: + - image: gcr.io/kpt-fn/set-namespace:v0.3.4 + configPath: package-context.yaml diff --git a/package-examples/ghost/README.md b/package-examples/ghost/README.md new file mode 100644 index 0000000000..c7b7650b05 --- /dev/null +++ b/package-examples/ghost/README.md @@ -0,0 +1,32 @@ +### Ghost Application + +"Ghost is a powerful app for new-media creators to publish, share, and grow a business around their content. It comes with modern tools to build a website, publish content, send newsletters & offer paid subscriptions to members." +https://ghost.org/ + +### Quick start + +#### Get KPT Pacakge +```bash +export NAMESPACE= +# make sure the namespace is correct and exists. Otherwise, create the namespace +kubectl create namespace ${NAMESPACE} + +# You get this Ghost package by running +kpt pkg get https://github.com/GoogleContainerTools/kpt.git/package-examples/ghost@main ${NAMESPACE} --for-deployment +``` + +#### Update the KRM resources to your own data + +Updating the KRM resources are easy with variant constructor +```bash +kpt fn render ${NAMESPACE} +``` + +#### Deploy the KRM resources to your cluster + +```bash +# Initialize inventory info. You only need to run this if do not have resourcesgroup.yaml +kpt live init ${NAMESPACE} + +kpt live apply ${NAMESPACE} +``` diff --git a/package-examples/ghost/crds/prometheusrules.yaml b/package-examples/ghost/crds/prometheusrules.yaml new file mode 100644 index 0000000000..f032a206ae --- /dev/null +++ b/package-examples/ghost/crds/prometheusrules.yaml @@ -0,0 +1,102 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.8.0 + creationTimestamp: null + name: prometheusrules.monitoring.coreos.com +spec: + group: monitoring.coreos.com + names: + categories: + - prometheus-operator + kind: PrometheusRule + listKind: PrometheusRuleList + plural: prometheusrules + shortNames: + - promrule + singular: prometheusrule + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: PrometheusRule defines recording and alerting rules for a Prometheus + instance + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Specification of desired alerting rule definitions for Prometheus. + properties: + groups: + description: Content of Prometheus rule file + items: + description: 'RuleGroup is a list of sequentially evaluated recording + and alerting rules. Note: PartialResponseStrategy is only used + by ThanosRuler and will be ignored by Prometheus instances. Valid + values for this field are ''warn'' or ''abort''. More info: https://github.com/thanos-io/thanos/blob/main/docs/components/rule.md#partial-response' + properties: + interval: + type: string + name: + type: string + partial_response_strategy: + type: string + rules: + items: + description: 'Rule describes an alerting or recording rule + See Prometheus documentation: [alerting](https://www.prometheus.io/docs/prometheus/latest/configuration/alerting_rules/) + or [recording](https://www.prometheus.io/docs/prometheus/latest/configuration/recording_rules/#recording-rules) + rule' + properties: + alert: + type: string + annotations: + additionalProperties: + type: string + type: object + expr: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + for: + type: string + labels: + additionalProperties: + type: string + type: object + record: + type: string + required: + - expr + type: object + type: array + required: + - name + - rules + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] \ No newline at end of file diff --git a/package-examples/ghost/ghost-app/Kptfile b/package-examples/ghost/ghost-app/Kptfile new file mode 100644 index 0000000000..7e6b432d88 --- /dev/null +++ b/package-examples/ghost/ghost-app/Kptfile @@ -0,0 +1,8 @@ +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: ghost-app + annotations: + config.kubernetes.io/local-config: "true" +info: + description: The Ghost App package contains the KRM resources for a Ghost Application. diff --git a/package-examples/ghost/ghost-app/deployment-ghost.yaml b/package-examples/ghost/ghost-app/deployment-ghost.yaml new file mode 100644 index 0000000000..0e64fcff65 --- /dev/null +++ b/package-examples/ghost/ghost-app/deployment-ghost.yaml @@ -0,0 +1,95 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ghost-app + namespace: example +spec: + replicas: 1 + strategy: + type: RollingUpdate + template: + spec: + affinity: + podAffinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + namespaces: + - "example" + topologyKey: kubernetes.io/hostname + weight: 1 + nodeAffinity: + securityContext: + fsGroup: 1001 + containers: + - name: ghost-app + image: docker.io/bitnami/ghost:4.45.0-debian-10-r0 + imagePullPolicy: "IfNotPresent" + securityContext: + runAsNonRoot: true + runAsUser: 1001 + env: + - name: BITNAMI_DEBUG + value: "false" + - name: ALLOW_EMPTY_PASSWORD + value: "yes" + - name: GHOST_DATABASE_HOST + value: "example-mariadb" + - name: GHOST_DATABASE_PORT_NUMBER + value: "3306" + - name: GHOST_DATABASE_NAME + value: "bitnami_ghost" + - name: GHOST_DATABASE_USER + value: "bn_ghost" + - name: GHOST_HOST + value: "aa/" + - name: GHOST_PORT_NUMBER + value: "2368" + - name: GHOST_USERNAME + value: "user" + - name: GHOST_EMAIL + value: "user@example.com" + - name: GHOST_BLOG_TITLE + value: "User's Blog" + - name: GHOST_ENABLE_HTTPS + value: "no" + - name: GHOST_EXTERNAL_HTTP_PORT_NUMBER + value: "80" + - name: GHOST_EXTERNAL_HTTPS_PORT_NUMBER + value: "443" + - name: GHOST_SKIP_BOOTSTRAP + value: "no" + ports: + - name: http + containerPort: 2368 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: "http" + scheme: HTTP + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 6 + successThreshold: 1 + readinessProbe: + httpGet: + path: / + port: "http" + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 5 + timeoutSeconds: 3 + failureThreshold: 6 + successThreshold: 1 + resources: + limits: {} + requests: {} + volumeMounts: + - name: ghost-data + mountPath: /bitnami/ghost + volumes: + - name: ghost-data + persistentVolumeClaim: + claimName: ghost-app diff --git a/package-examples/ghost/ghost-app/ingress-ghost.yaml b/package-examples/ghost/ghost-app/ingress-ghost.yaml new file mode 100644 index 0000000000..38f64ae528 --- /dev/null +++ b/package-examples/ghost/ghost-app/ingress-ghost.yaml @@ -0,0 +1,17 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ghost-app + namespace: example +spec: + rules: + - host: ghost.local + http: + paths: + - path: / + pathType: ImplementationSpecific + backend: + service: + name: ghost-app + port: + name: http diff --git a/package-examples/ghost/ghost-app/networkpolicy-ghost-ingress.yaml b/package-examples/ghost/ghost-app/networkpolicy-ghost-ingress.yaml new file mode 100644 index 0000000000..3ccfd1d6cf --- /dev/null +++ b/package-examples/ghost/ghost-app/networkpolicy-ghost-ingress.yaml @@ -0,0 +1,6 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: ghost-app +spec: + ingress: diff --git a/package-examples/ghost/ghost-app/package-context.yaml b/package-examples/ghost/ghost-app/package-context.yaml new file mode 100644 index 0000000000..6c33d9e4d7 --- /dev/null +++ b/package-examples/ghost/ghost-app/package-context.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: kptfile.kpt.dev + annotations: + config.kubernetes.io/local-config: "true" +data: + name: example diff --git a/package-examples/ghost/ghost-app/persistentvolumeclaim-ghost.yaml b/package-examples/ghost/ghost-app/persistentvolumeclaim-ghost.yaml new file mode 100644 index 0000000000..516a1fa4d1 --- /dev/null +++ b/package-examples/ghost/ghost-app/persistentvolumeclaim-ghost.yaml @@ -0,0 +1,12 @@ +# Source: ghost/templates/pvc.yaml +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: ghost-app + namespace: example +spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: "8Gi" diff --git a/package-examples/ghost/ghost-app/service-ghost.yaml b/package-examples/ghost/ghost-app/service-ghost.yaml new file mode 100644 index 0000000000..e2babe544a --- /dev/null +++ b/package-examples/ghost/ghost-app/service-ghost.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: ghost-app + namespace: example +spec: + type: LoadBalancer + externalTrafficPolicy: Cluster + sessionAffinity: None + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http diff --git a/package-examples/ghost/mariadb/Kptfile b/package-examples/ghost/mariadb/Kptfile new file mode 100644 index 0000000000..700ccd8140 --- /dev/null +++ b/package-examples/ghost/mariadb/Kptfile @@ -0,0 +1,8 @@ +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: mariadb + annotations: + config.kubernetes.io/local-config: "true" +info: + description: The MariaDB which provides the storage for Ghost. diff --git a/package-examples/ghost/mariadb/configmap-mariadb.yaml b/package-examples/ghost/mariadb/configmap-mariadb.yaml new file mode 100644 index 0000000000..85cf814999 --- /dev/null +++ b/package-examples/ghost/mariadb/configmap-mariadb.yaml @@ -0,0 +1,36 @@ +# Source: ghost/charts/mariadb/templates/primary/configmap.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: mariadb + namespace: example +data: + my.ini: |- + [mysqld] + skip-name-resolve + explicit_defaults_for_timestamp + basedir=/opt/bitnami/mariadb + plugin_dir=/opt/bitnami/mariadb/plugin + port=3306 + socket=/opt/bitnami/mariadb/tmp/mysql.sock + tmpdir=/opt/bitnami/mariadb/tmp + max_allowed_packet=16M + bind-address=* + pid-file=/opt/bitnami/mariadb/tmp/mysqld.pid + log-error=/opt/bitnami/mariadb/logs/mysqld.log + character-set-server=UTF8 + collation-server=utf8_general_ci + slow_query_log=0 + slow_query_log_file=/opt/bitnami/mariadb/logs/mysqld.log + long_query_time=10.0 + + [client] + port=3306 + socket=/opt/bitnami/mariadb/tmp/mysql.sock + default-character-set=UTF8 + plugin_dir=/opt/bitnami/mariadb/plugin + + [manager] + port=3306 + socket=/opt/bitnami/mariadb/tmp/mysql.sock + pid-file=/opt/bitnami/mariadb/tmp/mysqld.pid diff --git a/package-examples/ghost/mariadb/networkpolicy-mariadb-ingress.yaml b/package-examples/ghost/mariadb/networkpolicy-mariadb-ingress.yaml new file mode 100644 index 0000000000..c3f0756c30 --- /dev/null +++ b/package-examples/ghost/mariadb/networkpolicy-mariadb-ingress.yaml @@ -0,0 +1,7 @@ +# Source: ghost/charts/mariadb/templates/primary/networkpolicy-ingress.yaml +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: mariadb +spec: + ingress: diff --git a/package-examples/ghost/mariadb/package-context.yaml b/package-examples/ghost/mariadb/package-context.yaml new file mode 100644 index 0000000000..6c33d9e4d7 --- /dev/null +++ b/package-examples/ghost/mariadb/package-context.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: kptfile.kpt.dev + annotations: + config.kubernetes.io/local-config: "true" +data: + name: example diff --git a/package-examples/ghost/mariadb/prometheusrule-mariadb.yaml b/package-examples/ghost/mariadb/prometheusrule-mariadb.yaml new file mode 100644 index 0000000000..4bae214a72 --- /dev/null +++ b/package-examples/ghost/mariadb/prometheusrule-mariadb.yaml @@ -0,0 +1,10 @@ +# Source: ghost/charts/mariadb/templates/prometheusrules.yaml +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: mariadb + namespace: example +spec: + groups: + - name: mariadb + rules: [] diff --git a/package-examples/ghost/mariadb/service-mariadb.yaml b/package-examples/ghost/mariadb/service-mariadb.yaml new file mode 100644 index 0000000000..7455e23d7c --- /dev/null +++ b/package-examples/ghost/mariadb/service-mariadb.yaml @@ -0,0 +1,15 @@ +# Source: ghost/charts/mariadb/templates/primary/svc.yaml +apiVersion: v1 +kind: Service +metadata: + name: mariadb + namespace: example +spec: + type: ClusterIP + sessionAffinity: None + ports: + - name: mysql + port: 3306 + protocol: TCP + targetPort: mysql + nodePort: null diff --git a/package-examples/ghost/mariadb/serviceaccount-mariadb.yaml b/package-examples/ghost/mariadb/serviceaccount-mariadb.yaml new file mode 100644 index 0000000000..df58ad0273 --- /dev/null +++ b/package-examples/ghost/mariadb/serviceaccount-mariadb.yaml @@ -0,0 +1,7 @@ +# Source: ghost/charts/mariadb/templates/serviceaccount.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mariadb + namespace: example +automountServiceAccountToken: false diff --git a/package-examples/ghost/mariadb/statefulset-mariadb.yaml b/package-examples/ghost/mariadb/statefulset-mariadb.yaml new file mode 100644 index 0000000000..b45bc79563 --- /dev/null +++ b/package-examples/ghost/mariadb/statefulset-mariadb.yaml @@ -0,0 +1,78 @@ +# Source: ghost/charts/mariadb/templates/primary/statefulset.yaml +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mariadb + namespace: example +spec: + replicas: 1 + revisionHistoryLimit: 10 + serviceName: mariadb + updateStrategy: + type: RollingUpdate + template: + spec: + serviceAccountName: mariadb + affinity: + podAffinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + namespaces: + - "default" + topologyKey: kubernetes.io/hostname + weight: 1 + nodeAffinity: + securityContext: + fsGroup: 1001 + containers: + - name: mariadb + image: docker.io/bitnami/mariadb:10.6.7-debian-10-r62 + imagePullPolicy: "IfNotPresent" + securityContext: + runAsNonRoot: true + runAsUser: 1001 + env: + - name: BITNAMI_DEBUG + value: "false" + - name: MARIADB_USER + value: "bn_ghost" + - name: MARIADB_DATABASE + value: "bitnami_ghost" + ports: + - name: mysql + containerPort: 3306 + livenessProbe: + failureThreshold: 3 + initialDelaySeconds: 120 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + readinessProbe: + failureThreshold: 3 + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: + limits: {} + requests: {} + volumeMounts: + - name: data + mountPath: /bitnami/mariadb + - name: config + mountPath: /opt/bitnami/mariadb/conf/my.ini + subPath: my.ini + volumes: + - name: config + configMap: + name: mariadb + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: "8Gi" diff --git a/package-examples/ghost/package-context.yaml b/package-examples/ghost/package-context.yaml new file mode 100644 index 0000000000..6c33d9e4d7 --- /dev/null +++ b/package-examples/ghost/package-context.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: kptfile.kpt.dev + annotations: + config.kubernetes.io/local-config: "true" +data: + name: example