Compare commits

...

7 Commits
master ... k3s

Author SHA1 Message Date
9309724d37 feat(ingress): Add internal ingress and Prometheus integration 2023-07-30 18:44:16 +02:00
b8557ab571 feat(db): Migrate database and rework configuration
Add configuration entry for the new database paradigm, and reword the configuration pipeline to allow for better configuration maintainability and secret management.
2023-07-30 18:43:37 +02:00
347b1c79eb fix(db): Resource usage units 2023-05-07 14:11:51 +02:00
fbde0af4f3 feat(volumes): Add volumes definition 2023-05-07 14:08:09 +02:00
2271a34041 fix(db): Fix namespace miss spelling 2023-05-07 14:02:41 +02:00
31d324f03b feat(kustomization): Add database and namespace creation 2023-05-07 13:59:10 +02:00
9892d4bc2e feat(manifests): Add base configuration 2023-05-07 13:57:58 +02:00
10 changed files with 192 additions and 90 deletions

View File

@ -1,92 +1,5 @@
# Hassio # Hassio
## K8s
### Secret management
## Getting started On top of the standard database secret, an additional token needs to be generated from within Hassio to allow Prometheus scraping. This token need to be set within the k3s-secret project to be automatically provisionned in the cluster.
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://git.halia.dev/athens-school/Hassio.git
git branch -M master
git push -uf origin master
```
## Integrate with your tools
- [ ] [Set up project integrations](https://git.halia.dev/athens-school/Hassio/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

30
manifests/configmap.yaml Normal file
View File

@ -0,0 +1,30 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: homeassistant-config
namespace: home-automation
data:
configuration.yaml: |
default_config:
http:
ip_ban_enabled: false
login_attempts_threshold: -1
use_x_forwarded_for: true
trusted_proxies:
- 10.42.0.0/16
- 10.20.0.0/16
- 10.10.0.0/16
- 10.18.242.163/32
homeassistant:
name: Home
latitude: 55.656428
longitude: 12.552433
elevation: 4
unit_system: metric
time_zone: Europe/Copenhagen
external_url: http://hassio.beta.entos
internal_url: http://homeassistant-svc.home-automation.svc.cluster.local
frontend:
themes: !include_dir_merge_named themes
prometheus:
recorder: !include recorder.yaml

31
manifests/database.yaml Normal file
View File

@ -0,0 +1,31 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: homeassistant-db
namespace: home-automation
spec:
instances: 1
storage:
size: 1Gi
storageClass: flat-storage-class
bootstrap:
initdb:
database: homeassistant
owner: homeassistant
secret:
name: homeassistant-db
postgresql:
pg_hba:
- host all all all md5
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 500m
memory: 500Mi

48
manifests/deployment.yaml Normal file
View File

@ -0,0 +1,48 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: homeassistant
name: homeassistant
namespace: home-automation
spec:
selector:
matchLabels:
app: homeassistant
template:
metadata:
labels:
app: homeassistant
spec:
initContainers:
- name: config-binder
image: alpine
command: ["sh", "-c", "cp /binder/configuration.yaml /config/configuration.yaml"]
volumeMounts:
- mountPath: /binder/configuration.yaml
name: homeassistant-config
subPath: configuration.yaml
- mountPath: /config
name: homeassistant-data
containers:
- name: homeassistant
image: ghcr.io/home-assistant/home-assistant:stable
ports:
- containerPort: 8123
name: http
volumeMounts:
- mountPath: /config
name: homeassistant-data
- mountPath: /config/recorder.yaml
name: homeassistant-recorder
subPath: recorder.yaml
volumes:
- name: homeassistant-config
configMap:
name: homeassistant-config
- name: homeassistant-data
persistentVolumeClaim:
claimName: homeassistant-pvc
- name: homeassistant-recorder
secret:
secretName: homeassistant-recorder

19
manifests/ingress.yaml Normal file
View File

@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: homeassistant-ingress
namespace: home-automation
annotations:
kubernetes.io/ingress.class: "traefik-inter"
spec:
rules:
- host: hassio.beta.entos
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: homeassistant-svc
port:
number: 8123

View File

@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- service.yaml
- servicemonitor.yaml
- ingress.yaml
- configmap.yaml
- pvc.yaml
- database.yaml
- deployment.yaml

4
manifests/namespace.yaml Normal file
View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: home-automation

12
manifests/pvc.yaml Normal file
View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: homeassistant-pvc
namespace: home-automation
spec:
accessModes:
- ReadWriteOnce
storageClassName: flat-storage-class
resources:
requests:
storage: 1Gi

16
manifests/service.yaml Normal file
View File

@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: homeassistant-svc
namespace: home-automation
labels:
app.kubernetes.io/name: homeassistant
spec:
ports:
- name: http
protocol: TCP
port: 8123
targetPort: 8123
selector:
app: homeassistant

View File

@ -0,0 +1,17 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: homeassistant
namespace: home-automation
labels:
team: core
spec:
selector:
matchLabels:
app.kubernetes.io/name: homeassistant
endpoints:
- port: http
path: /api/prometheus
bearerTokenSecret:
key: token
name: hassio-prometheus-secret