-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from instana/ko-add-more-complex-example
feat: Add detailed GitOps example including upgrades via version pinning
- Loading branch information
Showing
11 changed files
with
223 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,25 @@ | |
### For more information on the Instana GitHub action for GitOps update, refer to: | ||
### https://github.com/instana/github-action-update-agent-configurations | ||
|
||
name: Instana GitOps update | ||
name: Instana GitOps update - Prod | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'renovate.json' | ||
- 'README.md' | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
push-gitops-config: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: instana/[email protected] | ||
with: | ||
# At least one of 'agent_zone' and 'agent_tags' should be set | ||
agent_zone: my_zone | ||
agent_tags: 'gitops_environment=prod' | ||
agent_zone: gitops-demo | ||
agent_tags: gitops_environment=prod | ||
env: | ||
INSTANA_API_ENDPOINT: ${{ secrets.INSTANA_API_ENDPOINT }} | ||
INSTANA_API_TOKEN: ${{ secrets.INSTANA_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# This workflow is used to create a PR with the existing agent version from the test branch to main | ||
|
||
name: Sync Agent Version to main | ||
|
||
# Controls when the workflow will run | ||
on: | ||
push: | ||
branches: [ "test" ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
open-pr: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
|
||
# Runs a set of commands using the runners shell | ||
- name: Copy AgentBootrap to main | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: | | ||
echo "Showing content of current AgentBootstrap" | ||
cat instana/com.instana.agent.bootstrap.AgentBootstrap.cfg | ||
rm -f /tmp/com.instana.agent.bootstrap.AgentBootstrap.cfg | ||
echo "Create temporary copy of the configuration file" | ||
cp instana/com.instana.agent.bootstrap.AgentBootstrap.cfg /tmp/ | ||
echo "Checking out main branch" | ||
git fetch origin main | ||
git checkout main | ||
echo "Creating new branch from main" | ||
git checkout -b promote-test-to-main | ||
echo "Replace config file on main" | ||
rm -f instana/com.instana.agent.bootstrap.AgentBootstrap.cfg | ||
cp -f /tmp/com.instana.agent.bootstrap.AgentBootstrap.cfg instana/com.instana.agent.bootstrap.AgentBootstrap.cfg | ||
echo "Check if file was changed" | ||
if [[ `git status --porcelain` ]]; then | ||
echo "The file has changed, continue to commit and push" | ||
else | ||
echo "The file is unchanged, main is already in sync with test branch, no further action needed" | ||
exit 0 | ||
fi | ||
echo "Setting git author" | ||
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
git config --global user.name "${GITHUB_ACTOR}" | ||
echo "Commiting change" | ||
git add instana/com.instana.agent.bootstrap.AgentBootstrap.cfg | ||
git commit -m "chore: Sync AgentBootstrap from current test branch" | ||
echo "Push change to feature branch" | ||
git push origin -f promote-test-to-main | ||
UPDATED_VERSION=$(cat instana/com.instana.agent.bootstrap.AgentBootstrap.cfg | grep "version = " | grep -v "#" | cut -c11-) | ||
PR_TITLE="chore(deps): Update Instana Agent Production to v${UPDATED_VERSION}" | ||
echo "Automated sync of instana/com.instana.agent.bootstrap.AgentBootstrap.cfg from branch \"test\" to \"main\"." > body-file.txt | ||
echo "Make sure that the test environment works as expected before approving and merging the change." >> body-file.txt | ||
echo "Merging will **trigger an production update including an agent restart**." >> body-file.txt | ||
echo "" >> body-file.txt | ||
echo "This update was driven by [this GitHub Action Workflow](https://github.com/instana/gitops-demo/blob/test/.github/workflows/sync-agent-version-to-main.yml)." >> body-file.txt | ||
echo "Available Instana Agent tags can be found on the [instana/agent-updates](https://github.com/instana/agent-updates/tags) repository." >> body-file.txt | ||
gh pr create -B main --title "${PR_TITLE}" --body-file "body-file.txt" --label "production" || \ | ||
gh pr edit -B main --title "${PR_TITLE}" --body-file "body-file.txt" --add-label "production" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This field specifies which version set of components should be used by the agent; | ||
# its value must be a valid tag from https://github.com/instana/agent-updates/tags | ||
# version = <tag> | ||
# renovate: datasource=github-tags depName=instana/agent-updates versioning=loose | ||
version = 2024.08.20.0843 | ||
|
||
# This field controls which set of components is used by the agent at runtime. | ||
productName = ${env:INSTANA_PRODUCT_NAME} | ||
|
||
origin = package dynamic |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
com.instana.plugin.host: | ||
tags: | ||
- gitops_environment=prod | ||
com.instana.plugin.generic.hardware: | ||
enabled: true | ||
availability-zone: gitops-demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": ["config:recommended", ":dependencyDashboard"], | ||
"baseBranches": ["test"], | ||
"customManagers": [ | ||
{ | ||
"customType": "regex", | ||
"fileMatch": ["instana/com.instana.agent.bootstrap.AgentBootstrap.cfg"], | ||
"matchStrings": [ | ||
"# renovate: datasource=(?<datasource>[a-z-]+?)(?: depName=(?<depName>.*?))(?: versioning=(?<versioning>[a-z-]+?))?\\sversion\\s=\\s(?<currentValue>.+?)\\s" | ||
], | ||
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}" | ||
} | ||
] | ||
} |