Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactor flux structure #11

Merged
merged 63 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
01da321
Refactor flux structure
nahsi Nov 24, 2024
5ccd529
Update controlplane
nahsi Nov 24, 2024
e37b5dc
Fix
nahsi Nov 24, 2024
336df95
F
nahsi Nov 24, 2024
c7f68fc
F
nahsi Nov 24, 2024
5f1806c
F
nahsi Nov 24, 2024
2af9862
F
nahsi Nov 24, 2024
26cfd32
Fix
nahsi Nov 24, 2024
75594e7
Install cilium with flux
nahsi Nov 24, 2024
0c30e48
Fix
nahsi Nov 24, 2024
56427ad
Typo
nahsi Nov 24, 2024
a9c1284
F
nahsi Nov 24, 2024
74c0add
F
nahsi Nov 24, 2024
0bb9189
F
nahsi Nov 24, 2024
4dcae69
Test
nahsi Nov 24, 2024
49788a4
F
nahsi Nov 24, 2024
fbee4a3
f
nahsi Nov 24, 2024
5eec315
F
nahsi Nov 24, 2024
63f3a3f
F
nahsi Nov 24, 2024
8f7b9a7
F
nahsi Nov 24, 2024
088ded7
F
nahsi Nov 24, 2024
732e404
F
nahsi Nov 24, 2024
c04858d
Fix
nahsi Nov 24, 2024
23bc77f
Add gethomepage
nahsi Nov 24, 2024
20b5409
F
nahsi Nov 24, 2024
5dd77ef
F
nahsi Nov 24, 2024
70d4785
F
nahsi Nov 24, 2024
5849491
F
nahsi Nov 24, 2024
20bcbc0
F
nahsi Nov 24, 2024
4cdcede
f
nahsi Nov 24, 2024
f54f2c8
F
nahsi Nov 24, 2024
1c0bcf9
F
nahsi Nov 24, 2024
6891798
f
nahsi Nov 24, 2024
5fb3307
F
nahsi Nov 24, 2024
d3aca0d
Fix
nahsi Nov 24, 2024
e42a143
F
nahsi Nov 24, 2024
f1d9ca0
F
nahsi Nov 24, 2024
23e8ab8
F
nahsi Nov 24, 2024
62761a3
Try to enable hubble and
nahsi Nov 24, 2024
d245fa5
Enable relay
nahsi Nov 24, 2024
240f0f3
F
nahsi Nov 24, 2024
f98e007
F
nahsi Nov 24, 2024
38c7760
F
nahsi Nov 24, 2024
d88aa04
F
nahsi Nov 24, 2024
c58df39
Add comment
nahsi Nov 24, 2024
8b7cedd
Hopefully fix
nahsi Nov 24, 2024
7691fe1
Fix?
nahsi Nov 24, 2024
466b71c
F
nahsi Nov 24, 2024
8633294
F
nahsi Nov 24, 2024
a8df062
F
nahsi Nov 24, 2024
dcc7583
F
nahsi Nov 24, 2024
d803b5f
F
nahsi Nov 24, 2024
76f63dc
F
nahsi Nov 24, 2024
96d547b
Just one instance but bigger
nahsi Nov 24, 2024
e482007
Concurency
nahsi Nov 24, 2024
7cfd927
Health check
nahsi Nov 24, 2024
29358a6
F
nahsi Nov 24, 2024
5b9bfe3
F
nahsi Nov 24, 2024
d8df636
Fix comment
nahsi Nov 24, 2024
6a66c7d
F
nahsi Nov 24, 2024
4b485f5
Use prod certs
nahsi Nov 24, 2024
50a1907
Update
nahsi Nov 24, 2024
1549b80
F
nahsi Nov 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .github/workflows/create-command.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "create"

on:
pull_request:
types:
- "labeled"
- "synchronize"
- "opened"
- "reopened"

jobs:
k8s:
if: >
contains(github.event.pull_request.labels.*.name, 'create') &&
!github.event.pull_request.head.repo.fork
uses: ./.github/workflows/terraform.yml
with:
command: create
workspace: "spectrum-${{ github.head_ref }}"
branch: ${{ github.event.pull_request.head.ref }}
secrets:
PAT: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }}
16 changes: 0 additions & 16 deletions .github/workflows/destroy-command.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/help-command.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/reset-command.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/slash.yml

This file was deleted.

65 changes: 48 additions & 17 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ on:
required: false
type: string
default: "main"
sha:
description: "Last commit in the branch"
required: false
type: string
secrets:
PAT:
description: "Used in Flux to clone the repo"
required: true

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"

jobs:
terraform:
runs-on: ubuntu-latest
Expand All @@ -41,14 +40,6 @@ jobs:
TF_VAR_github_branch: ${{ inputs.branch }}

steps:
- name: Set latest commit status as pending
if: inputs.sha
uses: myrotvorets/[email protected]
with:
sha: ${{ inputs.sha }}
token: ${{ secrets.PAT }}
status: pending

- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -81,6 +72,27 @@ jobs:
WORKSPACE="${WORKSPACE,,}" # Convert to lowercase
echo "workspace=${WORKSPACE}" >> $GITHUB_OUTPUT

- name: Find comment
if: inputs.command == 'create' || inputs.command == 'reset'
uses: peter-evans/find-comment@v3
id: comment
with:
token: ${{ secrets.PAT }}
issue-number: "${{ github.event.pull_request.number }}"
body-includes: "## ephemeral: ${{ steps.sanitize.outputs.workspace }}"

- name: Add comment
if: steps.comment.outputs.comment-id == null
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: "${{ steps.comment.outputs.comment-id }}"
token: ${{ secrets.PAT }}
issue-number: "${{ github.event.pull_request.number }}"
body: |
## ephemeral: ${{ steps.sanitize.outputs.workspace }}
Your instance is getting ready. Please wait.
edit-mode: replace

- name: Setup terraform
uses: hashicorp/setup-terraform@v3

Expand Down Expand Up @@ -111,16 +123,35 @@ jobs:
- name: Upload Artifacts
if: inputs.command == 'create' || inputs.command == 'reset'
uses: actions/upload-artifact@v4
id: artifact
with:
name: configs
path: |
terraform/kubeconfig
terraform/talosconfig

- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: inputs.sha && always()
- name: Update comment
if: inputs.command == 'create' || inputs.command == 'reset'
uses: peter-evans/create-or-update-comment@v3
with:
sha: ${{ inputs.sha }}
comment-id: "${{ steps.comment.outputs.comment-id }}"
token: ${{ secrets.PAT }}
status: ${{ job.status }}
issue-number: "${{ github.event.pull_request.number }}"
body: |
## ephemeral: ${{ steps.sanitize.outputs.workspace }}
Your ephemeral k8s cluster is ready.

Visit the dashboard at https://home.rnd-${{ steps.sanitize.outputs.workspace }}.fluence.dev

You can obtain kubeconfig and talos config from this [artifact](${{ steps.artifact.outputs.artifact-url }}).
Download and unarchive the artifact, then run this command to export variables:
```shell
[[ -f ./kubeconfig ]] && export KUBECONFIG=$(realpath ./kubeconfig)
[[ -f ./talosconfig ]] && export TALOSCONFIG=$(realpath ./talosconfig)
```

To get the token for kubernetes-dashboard auth run:
```shell
kubectl -n kubernetes-dashboard create token kubernetes-dashboard-admin
```
edit-mode: replace
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,7 @@

#### Create a cluster

Create a PR with changes and add a comment to PR:

```
/create
```

This will trigger the workflow that will setup talos cluster from you PR.
Comment

```
/help
```

to see all available commands.
Create a PR with changes and add a a label `create` to PR.

#### Download and export kubeconfig

Expand All @@ -40,9 +27,10 @@ export KUBECONFIG=./kubeconfig

https://kubernetes.io/docs/reference/kubectl/quick-reference/


## Misc

### Accessing kubernetes dashboard

```
kubectl -n kubernetes-dashboard create token kubernetes-dashboard-admin
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt
namespace: kube-system
namespace: cert-manager
spec:
acme:
email: [email protected]
# server: https://acme-v02.api.letsencrypt.org/directory
server: https://acme-staging-v02.api.letsencrypt.org/directory
server: https://acme-v02.api.letsencrypt.org/directory
# server: https://acme-staging-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: letsencrypt
solvers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cluster-issuer.yml
- secret.yml
7 changes: 7 additions & 0 deletions flux/apps/cert-manager/issuer/secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: digitalocean-token
namespace: cert-manager
data:
access-token: "${DOTOKEN}"
33 changes: 33 additions & 0 deletions flux/apps/cert-manager/ks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
name: cert-manager
namespace: flux-system
spec:
interval: 1m0s
path: ./flux/apps/cert-manager/manager
prune: true
sourceRef:
kind: GitRepository
name: spectrum
namespace: flux-system
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
name: cluster-issuer
namespace: flux-system
spec:
interval: 2m0s
path: ./flux/apps/cert-manager/issuer
prune: true
sourceRef:
kind: GitRepository
name: spectrum
namespace: flux-system
dependsOn:
- name: cert-manager
postBuild:
substituteFrom:
- kind: ConfigMap
name: terraform-config
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ks.yml
- namespace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: cert-manager
namespace: kube-system
namespace: cert-manager
spec:
interval: 30m
chart:
Expand Down
4 changes: 4 additions & 0 deletions flux/apps/cert-manager/namespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: cert-manager
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: external-dns
namespace: kube-system
namespace: external-dns
spec:
interval: 5m
chart:
Expand All @@ -20,7 +20,7 @@ spec:
valueFrom:
secretKeyRef:
name: digitalocean-token
key: token
key: access-token
txtOwnerId: "${PREFIX}"
sources:
- ingress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yml
- helm-release.yml
- helm-repository.yml
- secret.yml
4 changes: 4 additions & 0 deletions flux/apps/external-dns/namespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: external-dns
7 changes: 7 additions & 0 deletions flux/apps/external-dns/secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: digitalocean-token
namespace: external-dns
data:
access-token: "${DOTOKEN}"
4 changes: 4 additions & 0 deletions flux/apps/homepage/configs/bookmarks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Spectrum:
- Github:
- abbr: GH
href: https://github.com/fluencelabs/spectrum
1 change: 1 addition & 0 deletions flux/apps/homepage/configs/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions flux/apps/homepage/configs/kubernetes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mode: cluster
1 change: 1 addition & 0 deletions flux/apps/homepage/configs/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
10 changes: 10 additions & 0 deletions flux/apps/homepage/configs/settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Spectrum Dashboard
favicon: https://kubernetes.io/images/favicon.png
theme: dark
color: slate
target: _self
headerStyle: clean
layout:
Home:
style: row
columns: 4
Loading
Loading