-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add minikube
- Loading branch information
Showing
42 changed files
with
502 additions
and
302 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# name: Kubernetes Deployment | ||
|
||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
|
||
# jobs: | ||
# deploy: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - name: Set up Kubernetes CLI | ||
# uses: azure/setup-kubectl@v1 | ||
# with: | ||
# version: 'v1.21.0' | ||
# - name: Create MySQL and PostgreSQL Secrets | ||
# run: | | ||
# echo "$MYSQL_PASSWORD" | base64 | kubectl create secret generic mysql-secret \ | ||
# --from-literal=password=- \ | ||
# --dry-run=client -o yaml | kubectl apply -f - | ||
# echo "$POSTGRES_PASSWORD" | base64 | kubectl create secret generic postgres-secret \ | ||
# --from-literal=password=- \ | ||
# --dry-run=client -o yaml | kubectl apply -f - | ||
# env: | ||
# MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} | ||
# POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
# - name: Deploy | ||
# run: | | ||
# export $(cat kustomize.env | xargs) # Load and export env vars | ||
# kustomize build base | kubectl apply -f - |
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 |
---|---|---|
|
@@ -31,3 +31,5 @@ build/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
dist/ | ||
iac/**/.env |
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 |
---|---|---|
@@ -1,25 +1,59 @@ | ||
# Infrastructure as Code | ||
# zfgc.com | ||
|
||
This directory contains the infrastructure as code for the ZFGCBB project. | ||
Pizza. | ||
|
||
## Table of Contents | ||
## Environment Setup | ||
|
||
- [Infrastructure as Code](#infrastructure-as-code) | ||
- [Table of Contents](#table-of-contents) | ||
- [Requirements](#requirements) | ||
- [Getting Started](#getting-started) | ||
- [License](#license) | ||
### Install Dependencies | ||
|
||
## Requirements | ||
```bash | ||
cd iac/zfgc.com | ||
./scripts/bootstrap.sh | ||
``` | ||
|
||
- [Docker](https://docs.docker.com/get-docker/) | ||
- [Kubectl](https://kubernetes.io/docs/tasks/tools/) | ||
- [Kustomize](https://kustomize.io/) | ||
1. **Docker**: Ensure Docker is installed to build/test containers locally - [Get Docker](https://docs.docker.com/get-docker/). | ||
|
||
## Getting Started | ||
### Project Configuration | ||
|
||
For now, just look at [](zfgc.com/kube/README.md) | ||
1. **Secrets Management**: | ||
- Store sensitive data like database passwords securely. | ||
- Add MySQL and PostgreSQL passwords as secrets in your GitHub repository: | ||
|
||
- **MySQL Password**: Under `Settings > Secrets and variables > Actions > New repository secret`. | ||
- Name: `MYSQL_PASSWORD` | ||
- Value: Your MySQL password. | ||
|
||
- **PostgreSQL Password**: Under `Settings > Secrets and variables > Actions > New repository secret`. | ||
- Name: `POSTGRES_PASSWORD` | ||
- Value: Your PostgreSQL password. | ||
|
||
## Deployment Process | ||
|
||
### Deploying Locally with minikube | ||
|
||
Run the following command to start minikube: | ||
|
||
```bash | ||
./iac/zfgc.com/scripts/start-minikube.sh | ||
|
||
./iac/zfgc.com/scripts/setup-test.sh | ||
``` | ||
|
||
## Notes | ||
|
||
- **Customizing Values**: | ||
Modify `kustomize.env` and environment-specific overlays as needed for different settings. | ||
|
||
- **Service Endpoints**: | ||
Verify networking settings to ensure appropriate service access. | ||
|
||
- **Troubleshooting**: | ||
Check logs using `kubectl logs` for any deployment-related issues. | ||
|
||
## Contributions | ||
|
||
Feel free to contribute to the project by forking the repository, making changes, and submitting a pull request. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](../LICENSE) file for details. | ||
This project is licensed under the MIT License. |
File renamed without changes.
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,17 @@ | ||
# Namespace for isolation | ||
NAMESPACE=dev | ||
|
||
# File paths for services | ||
MYSQL_DIRECTORY=./dist/old-skool/mysql_data | ||
POSTGRES_DIRECTORY=./dist/zfg-bb/postgres_data | ||
APACHE_VHOST_CONFIG_DIRECTORY=./dist/old-skool/apache_vhosts | ||
|
||
# Secure MySQL and PostgreSQL passwords (set secure values in production) | ||
MYSQL_PASSWORD=your_mysql_password | ||
POSTGRES_PASSWORD=your_postgres_password | ||
|
||
# Apache Vhost config directory | ||
APACHE_VHOST_CONFIG_DIRECTORY=./dist/old-skool/apache_vhosts | ||
|
||
# Image name for zfg-bb (Spring Java project) | ||
ZFGBB_IMAGE_NAME=zfg-bb:latest |
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,33 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: postgres | ||
namespace: $(NAMESPACE) | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: postgres | ||
template: | ||
metadata: | ||
labels: | ||
app: postgres | ||
spec: | ||
containers: | ||
- name: postgres | ||
image: postgres:16 | ||
env: | ||
- name: POSTGRES_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: postgres-secret | ||
key: password | ||
ports: | ||
- containerPort: 5432 | ||
volumeMounts: | ||
- mountPath: /var/lib/postgresql/data | ||
name: postgres-vol | ||
volumes: | ||
- name: postgres-vol | ||
hostPath: | ||
path: $(postgres.directory) |
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,37 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: my-ingress | ||
namespace: my-namespace | ||
spec: | ||
rules: | ||
- host: zfgc.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: ImplementationSpecific | ||
backend: | ||
service: | ||
name: old-skool | ||
port: | ||
number: 80 | ||
- host: crystalrook.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: ImplementationSpecific | ||
backend: | ||
service: | ||
name: old-skool | ||
port: | ||
number: 80 | ||
- host: pizzatime.zfgc.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: ImplementationSpecific | ||
backend: | ||
service: | ||
name: zfg-bb | ||
port: | ||
number: 80 |
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,38 @@ | ||
namespace: $(NAMESPACE) | ||
|
||
resources: | ||
- namespace.yaml | ||
- old-skool/ | ||
- zfg-bb/ | ||
|
||
configMapGenerator: | ||
- literals: | ||
- apache.directory=$(APACHE_DIRECTORY) | ||
- mysql.directory=$(MYSQL_DIRECTORY) | ||
name: old-skool-config | ||
- literals: | ||
- postgres.directory=$(POSTGRES_DIRECTORY) | ||
name: zfg-bb-config | ||
|
||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
replacements: | ||
- source: | ||
kind: Namespace | ||
name: $(NAMESPACE) | ||
version: v1 | ||
- source: | ||
fieldPath: data.apache.directory | ||
kind: ConfigMap | ||
name: old-skool-config | ||
version: v1 | ||
- source: | ||
fieldPath: data.mysql.directory | ||
kind: ConfigMap | ||
name: old-skool-config | ||
version: v1 | ||
- source: | ||
fieldPath: data.postgres.directory | ||
kind: ConfigMap | ||
name: zfg-bb-config | ||
version: v1 |
2 changes: 1 addition & 1 deletion
2
iac/zfgc.com/kube/base/namespace.yml → iac/zfgc.com/base/namespace.yml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: ${NAMESPACE} | ||
name: $(NAMESPACE) |
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,8 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: postgres-secret | ||
namespace: $(NAMESPACE) | ||
type: Opaque | ||
data: | ||
password: <base64_encoded_password> |
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,11 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: postgres | ||
namespace: $(NAMESPACE) | ||
spec: | ||
ports: | ||
- port: 5432 | ||
targetPort: 5432 | ||
selector: | ||
app: postgres |
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,21 @@ | ||
resources: | ||
- ../../base | ||
- ../../services/zfg-bb | ||
|
||
namespace: dev-${NAMESPACE} | ||
|
||
configMapGenerator: | ||
- literals: | ||
- hostDir=/dev/path/to/tomcat | ||
name: tomcat-config | ||
- literals: | ||
- hostDir=/dev/path/to/postgres | ||
name: postgres-config | ||
|
||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
replacements: | ||
- source: | ||
fieldPath: metadata.name | ||
kind: Namespace | ||
name: dev-${NAMESPACE} |
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,39 @@ | ||
resources: | ||
- ../../base | ||
- ../../services | ||
|
||
namespace: prod-${NAMESPACE} | ||
|
||
configMapGenerator: | ||
- literals: | ||
- hostDir=/prod/path/to/apache | ||
name: apache-config | ||
- literals: | ||
- hostDir=/prod/path/to/mysql | ||
name: mysql-config | ||
- literals: | ||
- hostDir=/prod/path/to/tomcat | ||
name: tomcat-config | ||
- literals: | ||
- hostDir=/prod/path/to/postgres | ||
name: postgres-config | ||
|
||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
patches: | ||
- patch: | | ||
- op: remove | ||
path: /spec/rules/0 | ||
- op: remove | ||
path: /spec/rules/1 | ||
target: | ||
group: networking.k8s.io | ||
kind: Ingress | ||
name: my-ingress | ||
version: v1 | ||
replacements: | ||
- source: | ||
fieldPath: metadata.name | ||
kind: Namespace | ||
name: prod-${NAMESPACE} | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.