Skip to content

Commit 0008ccf

Browse files
committed
update
1 parent 17e94ec commit 0008ccf

File tree

2,640 files changed

+102359
-121245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,640 files changed

+102359
-121245
lines changed

.gitattributes

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# Deploying with OpenTofu
2+
3+
OpenTofu is an open-source infrastructure as code tool that allows you to define and provision infrastructure across multiple cloud providers. This guide will help you deploy Mixcore using OpenTofu.
4+
5+
## Prerequisites
6+
7+
- [OpenTofu](https://opentofu.org/docs/intro/install/) installed
8+
- Cloud provider CLI tools installed:
9+
- [AWS CLI](https://aws.amazon.com/cli/) for AWS
10+
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) for Azure
11+
- [gcloud CLI](https://cloud.google.com/sdk/docs/install) for GCP
12+
- [kubectl](https://kubernetes.io/docs/tasks/tools/) installed
13+
- [Helm](https://helm.sh/docs/intro/install/) installed
14+
15+
## Configuration
16+
17+
### Cloud Provider Setup
18+
19+
#### AWS
20+
```sh
21+
# Configure AWS credentials
22+
export AWS_ACCESS_KEY_ID=your_access_key
23+
export AWS_SECRET_ACCESS_KEY=your_secret_key
24+
```
25+
26+
#### Azure
27+
```sh
28+
# Login to Azure
29+
az login
30+
31+
# Set environment variables
32+
export ARM_SUBSCRIPTION_ID=your_subscription_id
33+
export ARM_TENANT_ID=your_tenant_id
34+
export ARM_CLIENT_ID=your_client_id
35+
export ARM_CLIENT_SECRET=your_client_secret
36+
```
37+
38+
#### GCP
39+
```sh
40+
# Login to GCP
41+
gcloud auth login
42+
gcloud auth application-default login
43+
44+
# Set project
45+
export GOOGLE_PROJECT=your_project_id
46+
```
47+
48+
### OpenTofu Configuration
49+
50+
1. Create a `terraform.tfvars` file:
51+
```hcl
52+
cloud_provider = "aws" # or "azure" or "gcp"
53+
cluster_name = "mixcore-cluster"
54+
sqlserver_password = "your_password"
55+
mysql_password = "your_password"
56+
redis_password = "your_password"
57+
```
58+
59+
2. Review and customize `values.yaml` for Helm configuration:
60+
```yaml
61+
# See cloud/opentofu/values.yaml for configuration options
62+
```
63+
64+
## Deployment
65+
66+
1. Initialize OpenTofu:
67+
```sh
68+
cd cloud/opentofu
69+
tofu init
70+
```
71+
72+
2. Plan the deployment:
73+
```sh
74+
tofu plan
75+
```
76+
77+
3. Apply the deployment:
78+
```sh
79+
tofu apply
80+
```
81+
82+
## Accessing the Application
83+
84+
1. Get the cluster endpoint:
85+
```sh
86+
tofu output cluster_endpoint
87+
```
88+
89+
2. Get the kubeconfig:
90+
```sh
91+
tofu output kubeconfig > kubeconfig.yaml
92+
export KUBECONFIG=kubeconfig.yaml
93+
```
94+
95+
3. Access services:
96+
- Main application: http://<load-balancer-ip>
97+
- SQL Server: <load-balancer-ip>:1433
98+
- MySQL: <load-balancer-ip>:3306
99+
- Redis: <load-balancer-ip>:6379
100+
101+
## Updating Configuration
102+
103+
1. Edit `values.yaml` for Helm configuration:
104+
```sh
105+
nano cloud/opentofu/values.yaml
106+
```
107+
108+
2. Apply changes:
109+
```sh
110+
tofu apply
111+
```
112+
113+
## Destroying Resources
114+
115+
To destroy all resources:
116+
```sh
117+
tofu destroy
118+
```
119+
120+
## CI/CD Integration
121+
122+
### GitHub Actions
123+
```yaml
124+
deploy-infra:
125+
needs: build-and-push
126+
runs-on: ubuntu-latest
127+
steps:
128+
- uses: actions/checkout@v3
129+
130+
- name: Setup OpenTofu
131+
uses: hashicorp/setup-terraform@v2
132+
with:
133+
terraform_version: "1.5.0"
134+
135+
- name: Deploy Infrastructure
136+
run: |
137+
cd cloud/opentofu
138+
tofu init
139+
tofu apply -auto-approve
140+
```
141+
142+
### GitLab CI/CD
143+
```yaml
144+
deploy-infra:
145+
stage: deploy
146+
image:
147+
name: hashicorp/terraform:light
148+
entrypoint: [""]
149+
script:
150+
- cd cloud/opentofu
151+
- terraform init
152+
- terraform apply -auto-approve
153+
only:
154+
- main
155+
```
156+
157+
## Troubleshooting
158+
159+
### Common Issues
160+
161+
1. **Authentication Errors**
162+
- Verify cloud provider credentials
163+
- Check environment variables
164+
- Ensure CLI tools are properly configured
165+
166+
2. **Resource Creation Failures**
167+
- Check resource quotas
168+
- Verify network configurations
169+
- Review cloud provider logs
170+
171+
3. **Kubernetes Connection Issues**
172+
- Verify kubeconfig
173+
- Check cluster status
174+
- Ensure proper RBAC permissions
175+
176+
### Logs and Monitoring
177+
178+
1. **OpenTofu Logs**
179+
```sh
180+
# Enable debug logging
181+
export TF_LOG=DEBUG
182+
tofu apply
183+
```
184+
185+
2. **Kubernetes Logs**
186+
```sh
187+
# View pod logs
188+
kubectl logs -f deployment/mixcore -n mixcore
189+
190+
# View resource usage
191+
kubectl top pods -n mixcore
192+
```
193+
194+
## Best Practices
195+
196+
1. **State Management**
197+
- Use remote state storage
198+
- Enable state locking
199+
- Regular state backups
200+
201+
2. **Security**
202+
- Use secrets management
203+
- Implement least privilege
204+
- Regular security audits
205+
206+
3. **Maintenance**
207+
- Regular updates
208+
- Backup procedures
209+
- Disaster recovery planning
210+
211+
## Additional Resources
212+
213+
- [OpenTofu Documentation](https://opentofu.org/docs)
214+
- [Kubernetes Documentation](https://kubernetes.io/docs)
215+
- [Helm Documentation](https://helm.sh/docs)
216+
- [Cloud Provider Documentation](https://docs.aws.amazon.com/index.html)

0 commit comments

Comments
 (0)