From 4ffd2811cdeb02607090f1bb70108687446fbcba Mon Sep 17 00:00:00 2001 From: dendipradigta Date: Sat, 16 Jan 2021 22:55:37 +0700 Subject: [PATCH 1/7] test deploy --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ab2607fb..fa087e6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM node:9 - +# test command WORKDIR /app RUN npm install -g contentful-cli From 6f2e3d752488f39fa103e4393519f67ff1e94a35 Mon Sep 17 00:00:00 2001 From: dendipradigta Date: Sun, 17 Jan 2021 17:45:10 +0700 Subject: [PATCH 2/7] test-helm --- helm-chart/Chart.yaml | 6 ++ helm-chart/templates/configmap.yaml | 10 +++ helm-chart/templates/deployment.yaml | 54 +++++++++++++ helm-chart/templates/ingress.yaml | 25 ++++++ helm-chart/templates/service.yaml | 17 ++++ helm-chart/values.yaml | 111 +++++++++++++++++++++++++++ 6 files changed, 223 insertions(+) create mode 100644 helm-chart/Chart.yaml create mode 100644 helm-chart/templates/configmap.yaml create mode 100644 helm-chart/templates/deployment.yaml create mode 100644 helm-chart/templates/ingress.yaml create mode 100644 helm-chart/templates/service.yaml create mode 100644 helm-chart/values.yaml diff --git a/helm-chart/Chart.yaml b/helm-chart/Chart.yaml new file mode 100644 index 00000000..f309bfb5 --- /dev/null +++ b/helm-chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +name: sample-nodejs-app +version: 5.5.7 +appVersion: 3.0.6 +description: sample-nodejs-app +mainte \ No newline at end of file diff --git a/helm-chart/templates/configmap.yaml b/helm-chart/templates/configmap.yaml new file mode 100644 index 00000000..d46ca281 --- /dev/null +++ b/helm-chart/templates/configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: vol-configs-{{ .Release.Name }} + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.metadata.name }} + part-of: {{ .Values.metadata.labels.partOf }} +data: +{{- toYaml .Values.configmap.data | nindent 2 }} \ No newline at end of file diff --git a/helm-chart/templates/deployment.yaml b/helm-chart/templates/deployment.yaml new file mode 100644 index 00000000..4ab66d29 --- /dev/null +++ b/helm-chart/templates/deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.metadata.name }} + namespace: {{ .Values.metadata.namespace }} + labels: + app: {{ .Values.metadata.name }} + part-of: {{ .Values.metadata.labels.partOf }} +spec: + selector: + matchLabels: + app: {{ .Values.metadata.name }} + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 2 + maxUnavailable: 0 + template: + metadata: + labels: + app: {{ .Values.metadata.name }} + part-of: {{ .Values.metadata.labels.partOf }} + spec: + tolerations: + {{- toYaml .Values.spec.tolerations | nindent 8 }} + affinity: + {{- toYaml .Values.spec.affinity | nindent 8 }} + containers: + - name: {{ .Values.metadata.name }} + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.port }} + + {{- if .Values.spec.containers.readinessProbe }} + readinessProbe: +{{ toYaml .Values.spec.containers.readinessProbe | indent 10 }} + {{- end }} + {{- if .Values.spec.containers.livenessProbe }} + livenessProbe: +{{ toYaml .Values.spec.containers.livenessProbe | indent 10 }} + {{- end }} + resources: + {{- toYaml .Values.spec.containers.resources | nindent 10 }} + securityContext: + {{- toYaml .Values.spec.containers.securityContext | nindent 10 }} + volumeMounts: + {{- toYaml .Values.spec.containers.volumeMounts | nindent 10 }} + env: + {{- toYaml .Values.spec.containers.env | nindent 10 }} + + volumes: + {{- toYaml .Values.spec.containers.volumes | nindent 8 }} + \ No newline at end of file diff --git a/helm-chart/templates/ingress.yaml b/helm-chart/templates/ingress.yaml new file mode 100644 index 00000000..efa8d1d6 --- /dev/null +++ b/helm-chart/templates/ingress.yaml @@ -0,0 +1,25 @@ +{{- $servicePort := .Values.service.port -}} +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: {{ .Values.metadata.name }} + namespace: {{ .Values.metadata.namespace }} + labels: + app: {{ .Values.metadata.name }} + part-of: {{ .Values.metadata.labels.partOf }} + + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + +spec: +{{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} +{{- end }} + +{{- if .Values.ingress.rules }} + rules: +{{ toYaml .Values.ingress.rules | indent 4 }} +{{- end }} diff --git a/helm-chart/templates/service.yaml b/helm-chart/templates/service.yaml new file mode 100644 index 00000000..aa2e5f16 --- /dev/null +++ b/helm-chart/templates/service.yaml @@ -0,0 +1,17 @@ +kind: Service +apiVersion: v1 +metadata: + name: {{ .Values.metadata.name }} + namespace: {{ .Values.metadata.namespace }} + labels: + app: {{ .Values.metadata.name }} + part-of: {{ .Values.metadata.labels.partOf }} +spec: + type: {{ .Values.service.type }} + selector: + app: {{ .Values.metadata.name }} + ports: + - name: {{ .Values.metadata.name }}-http + port: 80 + protocol: {{ .Values.service.protocol }} + targetPort: {{ .Values.service.port }} diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml new file mode 100644 index 00000000..cdaf6715 --- /dev/null +++ b/helm-chart/values.yaml @@ -0,0 +1,111 @@ +metadata: + name: sample-nodejs + namespace: staging + labels: + partOf: sample-nodejs + +service: + type: NodePort + port: 3000 + protocol: TCP + +image: + repository: dendipradigta/sample-nodejs + tag: TMP_IMAGE_VERSION + # tag: latest + pullPolicy: Always + +spec: + replicasCout: 1 + restartPolicy: OnFailure + + tolerations: [] + # - key: pool + # value: preemptible + + affinity: {} + # nodeAffinity: + # weight: 70 + # key: cloud.google.com/gke-preemptible + # operator: In + # values: + # - "true" + # podAntiAffinity: + # weight: 50 + # key: part-of + # operator: In + # values: + # - avalon + # topologyKey: "kubernetes.io/hostname" + + containers: {} + # command: ["/app/sample-nodejs","update", "recipe_with_promo"] + # readinessProbe: + # httpGet: + # path: /ping + # port: 7723 + # initialDelaySeconds: 10 + # periodSeconds: 5 + # timeoutSeconds: 5 + # livenessProbe: + # httpGet: + # path: /ping + # port: 7723 + # initialDelaySeconds: 10 + # periodSeconds: 5 + # timeoutSeconds: 5 + + # resources: + # limits: + # cpu: 100m + # memory: 200Mi + # requests: + # cpu: 50m + # memory: 100Mi + + # securityContext: + # capabilities: + # drop: + # - all + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 10002 + + # volumeMounts: + # - name: configs + # mountPath: /sample-nodejs + + # env: + # Uncomment this section to add container env variables + # - name: DB_HOST + # value: '10.11.0.32' + # - name: DB_password + # value: 'xxxxxxx' + + # volumes: + # - name: configs + # configMap: + # name: vol-configs-sample-nodejs + +configmap: {} + +ingress: + annotations: + kubernetes.io/ingress.class: "nginx" + nginx.ingress.kubernetes.io/configuration-snippet: | + proxy_set_header l5d-dst-override $service_name.$namespace.svc.cluster.local; + + tls: [] + # - secretName: star-kurio-me + + rules: + - host: sample.dendi.com + http: + paths: + - path: / + backend: + serviceName: sample-nodejs + servicePort: 80 + + + From 4f907c8b973f96d9c8c2e6852f2da6abc8a4d274 Mon Sep 17 00:00:00 2001 From: dendipradigta Date: Sun, 17 Jan 2021 18:12:01 +0700 Subject: [PATCH 3/7] init --- helm-chart/Chart.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/helm-chart/Chart.yaml b/helm-chart/Chart.yaml index f309bfb5..9bf1d760 100644 --- a/helm-chart/Chart.yaml +++ b/helm-chart/Chart.yaml @@ -1,6 +1,5 @@ apiVersion: v1 -name: sample-nodejs-app -version: 5.5.7 -appVersion: 3.0.6 +name: APP_NAME +version: TEMP_CHART_VERSION +appVersion: TEMP_APP_VERSION description: sample-nodejs-app -mainte \ No newline at end of file From f753c435be77c6c95041ffa7e34867c21c7f8b92 Mon Sep 17 00:00:00 2001 From: dendipradigta Date: Sun, 17 Jan 2021 18:37:36 +0700 Subject: [PATCH 4/7] update namespace --- helm-chart/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index cdaf6715..ccee984f 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -1,6 +1,6 @@ metadata: name: sample-nodejs - namespace: staging + namespace: production labels: partOf: sample-nodejs From 76179b1ba7442ea07407463492880ee9e660b2ba Mon Sep 17 00:00:00 2001 From: dendipradigta Date: Sun, 17 Jan 2021 19:02:03 +0700 Subject: [PATCH 5/7] update namespace --- helm-chart/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index cdaf6715..5087e94a 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -1,6 +1,6 @@ metadata: name: sample-nodejs - namespace: staging + namespace: TEMP_NAMESPACE labels: partOf: sample-nodejs From 056c9b05599778fccd9c14c34b8aa0293bb65e97 Mon Sep 17 00:00:00 2001 From: dendipradigta Date: Sun, 17 Jan 2021 19:07:51 +0700 Subject: [PATCH 6/7] lll --- .circleci/config.yml | 33 ------------ README.md | 125 +------------------------------------------ 2 files changed, 1 insertion(+), 157 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1f553c19..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: cypress/base:8 - steps: - - checkout - - restore_cache: # special step to restore the dependency cache - key: dependency-cache-{{ checksum "package.json" }} - - run: - name: install-npm-wee - command: npm install - - save_cache: # special step to save the dependency cache - key: dependency-cache-{{ checksum "package.json" }} - paths: - - ./node_modules - - run: - name: clone-e2e-test - command: git clone https://github.com/contentful/the-example-app-e2e-tests.git ./test/e2e - - run: - name: install-e2e-test - command: cd ./test/e2e && npm install - - run: - name: test - command: npm run test - - store_artifacts: - path: /tmp/artifact-1 - - destination: artifact-file-cypress-result_`date +%Y-%m-%d_%H-%M-%S` - - - store_artifacts: - path: /tmp/artifacts - diff --git a/README.md b/README.md index 3fb48f32..b5754e20 100644 --- a/README.md +++ b/README.md @@ -1,124 +1 @@ -## The node.js example app - -[![CircleCI](https://img.shields.io/circleci/project/github/contentful/the-example-app.nodejs.svg)](https://circleci.com/gh/contentful/the-example-app.nodejs) - -The node.js example app teaches the very basics of how to work with Contentful: - -- consume content from the Contentful Delivery and Preview APIs -- model content -- edit content through the Contentful web app - -The app demonstrates how decoupling content from its presentation enables greater flexibility and facilitates shipping higher quality software more quickly. - -Screenshot of the example app - -You can see a hosted version of `The node.js example app` on Heroku. - -## What is Contentful? - -[Contentful](https://www.contentful.com) provides a content infrastructure for digital teams to power content in websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster. - -## Requirements - -* Node 8 -* Git -* Contentful CLI (only for write access) - -Without any changes, this app is connected to a Contentful space with read-only access. To experience the full end-to-end Contentful experience, you need to connect the app to a Contentful space with read _and_ write access. This enables you to see how content editing in the Contentful web app works and how content changes propagate to this app. - -## Common setup - -Clone the repo and install the dependencies. - -```bash -git clone https://github.com/contentful/the-example-app.nodejs.git -cd the-example-app.nodejs -``` - -```bash -npm install -``` - -## Steps for read-only access - -To start the express server, run the following - -```bash -npm run start:dev -``` - -Open [http://localhost:3000](http://localhost:3000) and take a look around. - - -## Steps for read and write access (recommended) - -Step 1: Install the [Contentful CLI](https://www.npmjs.com/package/contentful-cli) - -Step 2: Login to Contentful through the CLI. It will help you to create a [free account](https://www.contentful.com/sign-up/) if you don't have one already. -``` -contentful login -``` -Step 3: Create a new space -``` -contentful space create --name 'My space for the example app' -``` -Step 4: [Seed](https://github.com/contentful/contentful-cli/tree/master/docs/space/seed) the new space with the example content model [`the-example-app`](https://github.com/contentful/content-models/tree/master/the-example-app). Replace the `SPACE_ID` with the id returned from the create command executed in step 3 -``` -contentful space seed -s '' -t the-example-app -``` -Step 5: Head to the Contentful web app's API section and grab `SPACE_ID`, `DELIVERY_ACCESS_TOKEN`, `PREVIEW_ACCESS_TOKEN`. - -Step 6: Open `variables.env` and inject your credentials so it looks like this - -``` -NODE_ENV=development -CONTENTFUL_SPACE_ID= -CONTENTFUL_DELIVERY_TOKEN= -CONTENTFUL_PREVIEW_TOKEN= -PORT=3000 -``` - -Step 7: To start the express server, run the following -```bash -npm run start:dev -``` -Final Step: - -Open [http://localhost:3000?editorial_features=enabled](http://localhost:3000?editorial_features=enabled) and take a look around. This URL flag adds an “Edit” button in the app on every editable piece of content which will take you back to Contentful web app where you can make changes. It also adds “Draft” and “Pending Changes” status indicators to all content if relevant. - -## Deploy to Heroku -You can also deploy this app to Heroku: - -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) - - -## Use Docker -You can also run this app as a Docker container: - -Step 1: Clone the repo - -```bash -git clone https://github.com/contentful/the-example-app.nodejs.git -``` - -Step 2: Build the Docker image - -```bash -docker build -t the-example-app.nodejs . -``` - -Step 3: Run the Docker container locally: - -```bash -docker run -p 3000:3000 -d the-example-app.nodejs -``` - -If you created your own Contentful space, you can use it by overriding the following environment variables: - -```bash -docker run -p 3000:3000 \ - -e CONTENTFUL_SPACE_ID= \ - -e CONTENTFUL_DELIVERY_TOKEN= \ - -e CONTENTFUL_PREVIEW_TOKEN= \ - -d the-example-app.nodejs -``` +ok \ No newline at end of file From 71300ee51eab8d3029cb4d6b486ee2432b8f6ff5 Mon Sep 17 00:00:00 2001 From: dendipradigta Date: Sun, 17 Jan 2021 20:41:05 +0700 Subject: [PATCH 7/7] test --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5754e20..196e06b3 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -ok \ No newline at end of file +testtttt \ No newline at end of file