restructure flux folders

This commit is contained in:
marcel-dempers 2023-03-11 10:06:53 +11:00
parent b898ab2bf9
commit 000a878d7b
9 changed files with 111 additions and 2 deletions

View File

@ -98,10 +98,47 @@ flux bootstrap github \
--path=kubernetes/fluxcd/clusters/dev-cluster \
--personal \
--branch fluxcd-2022
flux check
# flux manages itself using GitOps objects:
kubectl -n flux-system get GitRepository
kubectl -n flux-system get Kustomization
```
Check the source code that `flux bootstrap` created
```
git pull origin <branch-name>
```
```
# Repository structure
https://fluxcd.io/flux/guides/repository-structure/
* Mono Repo
* Repo per team
* Repo per app
```
- apps
- example-app-1
- example-app-2
- infrastructure
- ingress-nginx
- monitoring
- clusters
-dev-cluster
-prod-cluster
```
## build our app
```
cd kubernetes\fluxcd\apps\example-app-1\src
docker build . -t example-app-1:0.0.1
#load the image to our test cluster so we dont need to push to a registry
kind load docker-image example-app-1:0.0.1 --name fluxcd
```

View File

@ -20,7 +20,7 @@ metadata:
namespace: flux-system
spec:
interval: 10m0s
path: ./kubernetes/fluxcd/clusters/dev-cluster
path: ./kubernetes/fluxcd/repositories/config/clusters/dev-cluster
prune: true
sourceRef:
kind: GitRepository

View File

@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: example-app-1
data:
config.json: |
{
"environment" : "dev"
}

View File

@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-app-1
labels:
app: example-app-1
spec:
selector:
matchLabels:
app: example-app-1
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: example-app-1
spec:
containers:
- name: example-app-1
image: example-app-1:0.0.1
imagePullPolicy: Always
ports:
- containerPort: 5000
volumeMounts:
- name: config-volume
mountPath: /configs/
volumes:
- name: config-volume
configMap:
name: example-app-1

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: example-app-1
labels:
app: example-app-1
spec:
type: ClusterIP
selector:
app: example-app-1
ports:
- protocol: TCP
name: http
port: 80
targetPort: 5000

View File

@ -0,0 +1,6 @@
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"

View File

@ -0,0 +1,8 @@
FROM python:3.7.3-alpine3.9 as base
RUN pip install Flask==2.0.3
WORKDIR /app
COPY app.py /app/
ENV FLASK_APP=app.py
CMD flask run -h 0.0.0 -p 5000