From 8ee74b89ea66a564427ac259579e5916cbcc8ac5 Mon Sep 17 00:00:00 2001 From: ruokun-niu Date: Wed, 25 Sep 2024 10:46:48 -0700 Subject: [PATCH 1/7] postgres yaml file --- .../resources/drasi-postgres.yaml | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tutorial/getting-started/resources/drasi-postgres.yaml diff --git a/tutorial/getting-started/resources/drasi-postgres.yaml b/tutorial/getting-started/resources/drasi-postgres.yaml new file mode 100644 index 0000000..44a8fdd --- /dev/null +++ b/tutorial/getting-started/resources/drasi-postgres.yaml @@ -0,0 +1,74 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-data-init +data: + init.sql: > + CREATE TABLE "Message" ( + "MessageId" integer NOT NULL, + "From" character varying(50) NOT NULL, + "Message" character varying(200) NOT NULL + ); + + ALTER TABLE "Message" ADD CONSTRAINT pk_message + PRIMARY KEY ("MessageId"); + + INSERT INTO public."Message" VALUES (1, 'Buzz Lightyear', 'To infinity and beyond!'); + INSERT INTO public."Message" VALUES (2, 'Brian Kernighan', 'Hello World'); + INSERT INTO public."Message" VALUES (3, 'Antoninus', 'I am Spartacus'); + INSERT INTO public."Message" VALUES (4, 'David', 'I am Spartacus'); +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-pg-config + labels: + app: postgres +data: + POSTGRES_DB: hello-world + POSTGRES_USER: test + POSTGRES_PASSWORD: test +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgres +spec: + replicas: 1 + selector: + matchLabels: + app: postgres + template: + metadata: + labels: + app: postgres + spec: + containers: + - name: postgres + image: postgres:15-alpine + args: ["-c", "wal_level=logical"] + volumeMounts: + - name: init + mountPath: "/docker-entrypoint-initdb.d" + ports: + - containerPort: 5432 + envFrom: + - configMapRef: + name: test-pg-config + volumes: + - name: init + configMap: + name: test-data-init +--- +apiVersion: v1 +kind: Service +metadata: + name: postgres + labels: + app: postgres +spec: + type: ClusterIP + ports: + - port: 5432 + selector: + app: postgres From 0d44aef1b12109c4e1e6c88e6ce68e08e11511c0 Mon Sep 17 00:00:00 2001 From: ruokun-niu Date: Wed, 25 Sep 2024 11:31:32 -0700 Subject: [PATCH 2/7] testing release --- .github/workflows/release.yml | 42 +++++++++++++++++++ .../.devcontainer/devcontainer.json | 2 +- .../.devcontainer/post-create.sh | 4 +- .../resources/hello-world-source.yaml | 2 +- 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..45a2497 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Draft Release + +on: + workflow_dispatch: + inputs: + tag: + description: 'Version Tag' + required: true + +jobs: + getting_started: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Zip tutorial folder + run: | + zip -r quickstart-dev-container.zip tutorial/getting-started + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.event.inputs.tag }} + release_name: Release ${{ github.event.inputs.tag }} + draft: true + prerelease: false + + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./quickstart-dev-container.zip + asset_name: quickstart-dev-container.zip + asset_content_type: application/zip \ No newline at end of file diff --git a/tutorial/getting-started/.devcontainer/devcontainer.json b/tutorial/getting-started/.devcontainer/devcontainer.json index e09b178..8c86e5f 100644 --- a/tutorial/getting-started/.devcontainer/devcontainer.json +++ b/tutorial/getting-started/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "onCreateCommand": "sed -i 's/\r$//' ./.devcontainer/post-create.sh && sed -i 's/\r$//' ./.devcontainer/on-create.sh && bash ./.devcontainer/on-create.sh", "postCreateCommand": "bash ./.devcontainer/post-create.sh", - "postStartCommand": "nohup bash -c 'kubectl port-forward svc/postgres 5432:5432 -n drasi-system &'", + "postStartCommand": "nohup bash -c 'kubectl port-forward svc/postgres 5432:5432 &'", "runArgs": [ "--privileged", "--init" diff --git a/tutorial/getting-started/.devcontainer/post-create.sh b/tutorial/getting-started/.devcontainer/post-create.sh index ed6dd2b..36d82dd 100644 --- a/tutorial/getting-started/.devcontainer/post-create.sh +++ b/tutorial/getting-started/.devcontainer/post-create.sh @@ -17,6 +17,6 @@ sudo apt-get update sudo apt-get install --no-install-recommends --assume-yes postgresql-client ## Install PostgreSQL on K3d -kubectl apply -f https://drasi.blob.core.windows.net/installs/drasi-postgres.yaml -n drasi-system +kubectl apply -f https://raw.githubusercontent.com/drasi-project/learning/main/tutorial/getting-started/resources/drasi-postgres.yaml sleep 15 -kubectl wait --for=condition=ready pod -l app=postgres -n drasi-system --timeout=60s \ No newline at end of file +kubectl wait --for=condition=ready pod -l app=postgres --timeout=60s \ No newline at end of file diff --git a/tutorial/getting-started/resources/hello-world-source.yaml b/tutorial/getting-started/resources/hello-world-source.yaml index e89ab99..5496ead 100644 --- a/tutorial/getting-started/resources/hello-world-source.yaml +++ b/tutorial/getting-started/resources/hello-world-source.yaml @@ -4,7 +4,7 @@ name: hello-world spec: kind: PostgreSQL properties: - host: postgres + host: postgres.default.svc.cluster.local user: test port: 5432 ssl: false From f1b082bea415697a2af721105489a21bc7ede56a Mon Sep 17 00:00:00 2001 From: ruokun-niu Date: Wed, 25 Sep 2024 11:37:56 -0700 Subject: [PATCH 3/7] debug --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45a2497..68ba58a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ name: Draft Release on: + push: workflow_dispatch: inputs: tag: From 12b9cb19d77ca52a89c6aab7b2ab5825f47a2b60 Mon Sep 17 00:00:00 2001 From: ruokun-niu Date: Wed, 25 Sep 2024 11:38:24 -0700 Subject: [PATCH 4/7] revert --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 68ba58a..45a2497 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,6 @@ name: Draft Release on: - push: workflow_dispatch: inputs: tag: From 9d701f925de8e035caf0055fa76b3bede313ab10 Mon Sep 17 00:00:00 2001 From: ruokun-niu Date: Wed, 25 Sep 2024 11:43:52 -0700 Subject: [PATCH 5/7] updated release name --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45a2497..4bbbaa1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.event.inputs.tag }} - release_name: Release ${{ github.event.inputs.tag }} + release_name: ${{ github.event.inputs.tag }} draft: true prerelease: false From 11363ac27e72cbb374bef7d0c51035f3a124fa1e Mon Sep 17 00:00:00 2001 From: ruokun-niu Date: Wed, 25 Sep 2024 11:51:46 -0700 Subject: [PATCH 6/7] release command --- .github/workflows/release.yml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bbbaa1..25045cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,23 +20,5 @@ jobs: zip -r quickstart-dev-container.zip tutorial/getting-started - name: Create GitHub Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.event.inputs.tag }} - release_name: ${{ github.event.inputs.tag }} - draft: true - prerelease: false - - - - name: Upload release asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./quickstart-dev-container.zip - asset_name: quickstart-dev-container.zip - asset_content_type: application/zip \ No newline at end of file + run: | + gh release create ${{ inputs.tag }} quickstart-dev-container.zip --draft --title ${{ inputs.tag }} \ No newline at end of file From 011d26743340794ce649e849c01172af7ee468f8 Mon Sep 17 00:00:00 2001 From: ruokun-niu Date: Wed, 25 Sep 2024 11:54:01 -0700 Subject: [PATCH 7/7] config env --- .github/workflows/release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 25045cc..e5d72e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,11 @@ on: jobs: getting_started: + permissions: + contents: write + packages: read + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} runs-on: ubuntu-latest steps: