From 1f2d52deeb8928da1e4131732e3c7859776b78bd Mon Sep 17 00:00:00 2001 From: Vladyslav Kurmaz Date: Sat, 8 Jun 2024 20:21:38 +0300 Subject: [PATCH] feat: whoami (#47) * feat: bump version to 24.5.0 * feat: whoami deployment * fix(ci): versions * fix(ci): versions * fix(ci): move Sonar to the build job * fix: remove test host from whoami --- .github/workflows/build.yml | 24 +++++-------- .tln.conf | 33 +++++++++++------- aws/app/charts/nginx/values.yaml | 5 +-- sonar-project.properties | 6 ++-- version | 2 +- whoami.yaml | 58 ++++++++++++++++++++++++++++++++ 6 files changed, 94 insertions(+), 34 deletions(-) create mode 100644 whoami.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d815264..03e277a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,31 +5,25 @@ on: - main pull_request: types: [opened, synchronize, reopened] - workflow_dispatch: + workflow_dispatch: jobs: buildandtest: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/setup-node@v4 with: - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: 16 + node-version: "20.9.0" + - name: Install tln cli - run: | - npm i -g tln-cli@1.61.0 - tln --version - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + run: npm i -g tln-cli@1.102.0 && tln --version + + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.tln.conf b/.tln.conf index bd9e760..a8e7bcb 100644 --- a/.tln.conf +++ b/.tln.conf @@ -143,6 +143,7 @@ module.exports = { .option('plan', { describe: 'Run Terraform plan', default: false, type: 'boolean' }) .option('apply', { describe: 'Run Terraform apply', default: false, type: 'boolean' }) .option('auto-approve', { describe: 'Tun on auto approve for apply & destroy', default: false, type: 'boolean' }) + .option('delete', { describe: 'Resources deletion modifier', default: false, type: 'boolean' }) .option('layers', { describe: 'Select which layers will be included', default: null, type: 'string' }) .option('bastion', { describe: 'Bastion address in form user@ip', default: null, type: 'string' }) .option('conn-opts', { describe: 'Connection options for sshuttle: [: { script.set([ `tln sshuttle -- --conn-opts ${script.env.TLN_CLOUDS_CONN_OPTS} --bastion $(tln get-bastion -- --conn-opts ${script.env.TLN_CLOUDS_CONN_OPTS})` - ]); - } - }, + ]); + } + }, + { id: 'whoami', builder: async (tln, script) => { + const op = script.env.TLN_CLOUDS_DELETE ? 'delete' : 'apply'; + script.set([ + `kubectl ${op} -f ${path.join(__dirname, 'whoami.yaml')}` + ]); + } + }, + { id: 'disconnect', builder: async (tln, script) => { + script.set([ + `pkill -f sshuttle` + ]); + } + }, { id: 'up', builder: async (tln, script) => { const opts = getTerraformOpts(script.env); script.set([` diff --git a/aws/app/charts/nginx/values.yaml b/aws/app/charts/nginx/values.yaml index 509f365..fe36716 100644 --- a/aws/app/charts/nginx/values.yaml +++ b/aws/app/charts/nginx/values.yaml @@ -7,5 +7,6 @@ controller: targetPorts: https: http config: - use-proxy-protocol: false - ssl-redirect: true + use-proxy-protocol: "false" + use-forwarded-headers: "true" + ssl-redirect: "true" diff --git a/sonar-project.properties b/sonar-project.properties index ccc94a5..f45b0fa 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,10 +3,10 @@ sonar.organization=project-talan # This is the name and version displayed in the SonarCloud UI. sonar.projectName=tln-clouds -sonar.projectVersion=22.11.0 +sonar.projectVersion=24.6.0-dev # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -sonar.sources=aws,azure,do,gcp,shared +sonar.sources=./aws,./azure,./do,./gcp,./shared # Encoding of the source code. Default is default system encoding -sonar.sourceEncoding=UTF-8 \ No newline at end of file +sonar.sourceEncoding=UTF-8 diff --git a/version b/version index 071c786..45f6bc2 100644 --- a/version +++ b/version @@ -1 +1 @@ -24.4.1 \ No newline at end of file +24.6.0-dev \ No newline at end of file diff --git a/whoami.yaml b/whoami.yaml new file mode 100644 index 0000000..560f187 --- /dev/null +++ b/whoami.yaml @@ -0,0 +1,58 @@ +apiVersion: v1 +kind: Service +metadata: + name: whoami +spec: + selector: + component: whoami + ports: + - protocol: TCP + port: 80 + targetPort: 80 + name: http +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: whoami +spec: + replicas: 1 + selector: + matchLabels: + component: whoami + template: + metadata: + labels: + component: whoami + annotations: + rollme: "{{ randAlphaNum 5 | quote }}" + spec: + restartPolicy: Always + containers: + - name: whoami + image: traefik/whoami + imagePullPolicy: Always + ports: + - name: http + containerPort: 80 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-whoami + annotations: + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/rewrite-target: "/$2" +spec: + rules: + - host: "" + http: + paths: + - path: "/whoami(/|$)(.*)" + pathType: "ImplementationSpecific" + backend: + service: + name: whoami + port: + number: 80 + ingressClassName: nginx