Skip to content

Commit 61ecab6

Browse files
Merge pull request #184 from dulajdilshan/deploy-consolidated-packages
Add configuration best practices, consolidated packages usages, and improvements for deployment guides
2 parents 319dccc + c1f676e commit 61ecab6

File tree

14 files changed

+529
-88
lines changed

14 files changed

+529
-88
lines changed
37.6 KB
Loading

en/docs/deploy/containerized-deployment/deploy-as-docker-image.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ Follow the steps below to execute the Docker image.
1818
1. Execute the docker images command to verify if the Docker image is generated.
1919

2020
```bash
21-
$ docker images
22-
REPOSITORY TAG IMAGE ID CREATED SIZE
23-
fake_store_manager latest e971e4336f71 58 minutes ago 237MB
21+
docker images
22+
```
23+
24+
The output will be similar to the following:
25+
26+
```bash
27+
REPOSITORY TAG IMAGE ID CREATED SIZE
28+
fake_store_manager latest e971e4336f71 58 minutes ago 237MB
2429
```
2530

2631
2. Execute the `docker run -d -v <path/to/config>/Config.toml:/home/ballerina/Config.toml -p 8090:8090 fake_store_manager:latest` command to run the generated Docker image.

en/docs/deploy/containerized-deployment/deploy-on-kubernetes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This guide explains how to deploy an integration in a Kubernetes cluster.
1414

1515
- Specify the container image details by creating a `Cloud.toml` file.
1616

17-
```
17+
```toml
1818
[container.image]
1919
repository="wso2inc" # Docker hub repository name.
2020
name="greeter" # container name
@@ -55,8 +55,8 @@ This guide explains how to deploy an integration in a Kubernetes cluster.
5555
## Step 3: Push the Docker image
5656

5757
Execute the command below to push the created Docker image into Docker Hub for the cluster to get access to the previously built container.
58-
```
59-
$ docker push wso2inc/greeter:latest
58+
```bash
59+
docker push wso2inc/greeter:latest
6060
```
6161

6262
???+ Note
@@ -73,8 +73,8 @@ This guide explains how to deploy an integration in a Kubernetes cluster.
7373

7474
Execute the command below to deploy the application into the Kubernetes cluster.
7575

76-
```
77-
$ kubectl apply -f /home/example/greeter/target/kubernetes/greeter
76+
```bash
77+
kubectl apply -f /home/example/greeter/target/kubernetes/greeter
7878
```
7979
You view the output below.
8080

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
# Configuration Best Practices
2+
3+
This guide covers configuration management strategies across deployment models (VM-based, containerized, Kubernetes) and CI/CD pipelines. Core principle: configuration is injected at runtime, never embedded in artifacts.
4+
5+
## VM-based deployments
6+
7+
### Centralized approach
8+
9+
All services share a single configuration management point.
10+
11+
#### Structure
12+
- Base configuration: `/opt/integrations/shared/Config.toml`
13+
- Environment overrides: `/opt/integrations/environments/{env}/Config.{env}.toml`
14+
- Endpoints: `/opt/integrations/environments/{env}/endpoints.{env}.toml`
15+
- Secrets: `/opt/integrations/environments/{env}/secrets.{env}.toml`
16+
17+
#### Loading
18+
Create a loader script that combines files in precedence order: secrets → environment-specific → base.
19+
20+
#### Management
21+
All services use the same configuration loader mechanism. Update configurations in one place.
22+
23+
### Decentralized approach
24+
25+
Each service maintains its own configuration independently.
26+
27+
#### Structure
28+
- Per service: `/opt/integrations/{service-name}/conf/base.toml`, `production.toml`, `secrets.production.toml`
29+
30+
#### Loading
31+
Each service's systemd file references its own configuration via `BAL_CONFIG_FILES`.
32+
33+
#### Management
34+
Services are deployed and configured independently. Good for teams owning individual services.
35+
36+
## Containerized deployments
37+
38+
???+ Warning
39+
Do NOT include `Config.toml` in the container image.
40+
41+
### Configuration injection methods
42+
43+
1. Volume mounts: `-v /path/to/Config.toml:/home/ballerina/conf/Config.toml`
44+
2. Environment variables: `-e BAL_CONFIG_VAR_PORT=9090`
45+
3. Docker Compose: Reference external config files via `.env` files
46+
47+
### Docker Compose pattern
48+
49+
Use environment files (`.env.development`, `.env.production`) to define environment-specific values. Mount configuration files as read-only volumes. Each environment has a separate config directory.
50+
51+
### Docker Swarm
52+
53+
Use Docker Secrets for sensitive data, Docker Configs for non-sensitive configuration. Reference them in service definitions.
54+
55+
## Kubernetes deployments
56+
57+
### Configuration resources
58+
59+
#### ConfigMap
60+
Non-sensitive configuration
61+
62+
- Base application config
63+
- Endpoint definitions
64+
- Feature flags
65+
66+
#### Secrets
67+
Sensitive data
68+
69+
- Database passwords
70+
- API keys
71+
- JWT secrets
72+
73+
### Configuration delivery
74+
75+
1. ConfigMap volumes mount as read-only files at `/etc/config/`
76+
2. Secret volumes mount with restricted permissions at `/etc/secrets/`
77+
3. Individual values are injected as environment variables
78+
79+
### Environment management with kustomize
80+
81+
Use kustomize overlays for environment progression:
82+
83+
- `base/`: Common manifests
84+
- `overlays/development/`: Dev-specific ConfigMaps and patches
85+
- `overlays/staging/`: Staging overrides
86+
- `overlays/production/`: Production overrides
87+
88+
Deploy with: `kubectl apply -k overlays/production/`
89+
90+
## CI/CD configuration handling
91+
92+
### Build process
93+
Build WITHOUT the configuration files. Create deployment artifacts independent of environment.
94+
95+
### Deployment process
96+
Each stage applies environment-specific configuration before updating the application:
97+
98+
1. Dev deployment: Apply dev ConfigMaps/Secrets → Update image
99+
2. Staging deployment: Apply staging ConfigMaps/Secrets → Update image
100+
3. Production deployment: Apply production ConfigMaps/Secrets → Update image (with manual approval)
101+
102+
### Configuration storage
103+
- Keep config files in repository (`config/` or `k8s/` directories)
104+
- Store secrets in platform secret storage (never in repo)
105+
- Each environment has separate secrets
106+
107+
### Pattern across platforms
108+
GitHub Actions, GitLab CI, and Jenkins follow the same: build once, configure per environment, deploy many times.
109+
110+
## Configuration promotion
111+
112+
Configuration flows through environments: development → staging → production.
113+
114+
### Promotion workflow
115+
116+
1. Validate source environment configuration
117+
2. Backup existing target configuration
118+
3. Copy with environment-specific transformations
119+
4. Validate transformed configuration
120+
5. Apply to the target environment
121+
6. Audit log all changes
122+
123+
### Transformations
124+
125+
#### Dev to staging
126+
127+
- Change: `dev.example.com``staging.example.com`
128+
- Keep: Authentication details unchanged
129+
- Adjust: Resource limits if needed
130+
131+
#### Staging to production
132+
133+
- Change: `staging.example.com``prod.example.com`
134+
- Increase: Log level requirements
135+
- Enable: Additional monitoring/security
136+
137+
### Automation tools
138+
139+
Automate promotion scripts that:
140+
141+
- Validate before proceeding
142+
- Log all changes
143+
- Enable rollback
144+
- Handle transformation rules
145+
146+
## Endpoint promotion
147+
148+
External and internal service endpoints change across environments.
149+
150+
### Endpoint configuration structure
151+
152+
```toml
153+
[external_services.development]
154+
auth_service = "https://auth-dev.example.com"
155+
156+
[external_services.staging]
157+
auth_service = "https://auth-staging.example.com"
158+
159+
[external_services.production]
160+
auth_service = "https://auth.example.com"
161+
```
162+
163+
### Endpoint resolution
164+
165+
During application startup:
166+
167+
- Read `endpoints.toml`
168+
- Select the correct endpoint block based on the `ENVIRONMENT` variable
169+
- Use the selected endpoint for all outbound connections
170+
171+
### Endpoint promotion
172+
173+
Promote independently from the general configuration:
174+
175+
1. Extract source environment endpoint block
176+
2. Transform domain/URLs to target pattern
177+
3. Apply to the target environment
178+
4. Validate connectivity to new endpoints
179+
5. Document changes in the audit log
180+
181+
## Common best practices
182+
183+
### Separation
184+
185+
Configuration should be separate from code and artifacts.
186+
187+
### Precedence management
188+
189+
Leverage configuration precedence order correctly:
190+
191+
1. Environment variables (highest priority)
192+
2. Command-line arguments
193+
3. TOML files
194+
4. Embedded defaults (lowest priority)
195+
196+
### Secrets security
197+
198+
- Never commit secrets to version control
199+
- Use platform secret management (Vault, K8s Secrets, CI/CD secrets)
200+
- Rotate secrets regularly
201+
- Audit all secret access
202+
203+
### Validation
204+
205+
Validate the configuration at startup.
206+
207+
- Check required values present
208+
- Validate value ranges and formats
209+
- Fail fast on invalid configuration
210+
211+
### Documentation
212+
213+
Maintain the endpoint and the configuration documentation.
214+
215+
- Example configuration files (Config.toml.example)
216+
- Endpoint registry showing all external/internal endpoints
217+
- Document transformation rules for promotions
218+
219+
### Auditability
220+
221+
Log all configuration changes.
222+
223+
- Who changed what
224+
- When changes occurred
225+
- Source and target environments
226+
- Rollback actions
227+
228+
## References
229+
230+
- [Managing Configurations](/deploy/managing-configurations)
231+
- [Kubernetes ConfigMaps & Secrets](https://kubernetes.io/docs/tasks/configure-pod-container/)
232+
- [Docker Compose Documentation](https://docs.docker.com/compose/)
233+
- [Kustomize](https://kustomize.io/)
234+
- [HashiCorp Vault](https://www.vaultproject.io/)

en/docs/deploy/deployment-best-practices/network-level-security.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ Implement high availability (HA) and failover configurations to ensure continuou
66

77
* **Cloud-native deployments:** Achieve high availability through the container orchestration platform (e.g., Kubernetes).
88

9-
* **VM-based deployments:** Use a minimum of two nodes configured for failover to maintain service continuity.
9+
* **VM-based deployments:** Deploy a minimum of two nodes configured for active-active or active-passive failover to maintain service continuity. For critical production environments with strict availability SLAs, consider three or more nodes.
1010

1111
Continuously monitor the health and performance of all nodes within the cluster. Track key metrics such as resource utilization, response time anomalies, and the volume of incoming network connections. Effective monitoring helps you determine when to add failover instances or adjust network routing to prevent service disruptions.
1212

1313
## Maintain network-level logging
1414

15-
Enable and retain logs for all network components, including proxy servers, load balancers, and other critical infrastructure devices. Regularly review these logs to detect abnormal behavior, unauthorized access attempts, or configuration changes.
15+
Enable and retain logs for all network components, including proxy servers, load balancers, and other critical infrastructure devices. Review these logs regularly to detect abnormal behavior, unauthorized access attempts, or configuration changes.
1616

1717
## Audit open ports and services
1818

19-
Conduct periodic network scans to identify open ports and active services. Ensure that only the ports necessary for your WSO2 products are accessible on both internal and external networks. Disable or monitor any additional open ports that are not explicitly required.
19+
Conduct periodic network scans to identify open ports and active services. Use tools such as nmap, netstat, or ss for port scanning. Ensure that only the ports necessary for your WSO2 products are accessible on both internal and external networks. Disable or monitor any additional open ports that are not explicitly required.
2020

2121
## Enforce device-level security
2222

en/docs/deploy/deployment-best-practices/os-level-security.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@
44

55
Use a dedicated OS-level user account to run WSO2 products. Assign only the minimum permissions necessary for running the product. Avoid using the root or administrator account, as these have full privileges by default and increase the risk of security breaches.
66

7+
Recommended permissions for the dedicated user:
8+
9+
* Read and execute access to the application directory
10+
* Read and write access to the log directory
11+
* Read access to configuration files
12+
* No sudo or administrative privileges
13+
714
## Minimize installed software
815
Install only the software and packages required for your WSO2 product deployment. Unnecessary software can introduce vulnerabilities. Regularly review and monitor installed packages.
916

1017
Refer to the [system requirements](/references/system-requirements) for details on the minimum required software.
1118

1219
## Enable the firewall
13-
Enable and configure a host-level firewall (e.g., iptables) to protect inbound and outbound connections. Only open the ports that are required for product functionality.
20+
Enable and configure a host-level firewall (e.g., iptables, UFW, or firewalld) to protect inbound and outbound connections. Only open the ports that are required for product functionality.
1421

1522
## Restrict access to clustering ports
1623

17-
Apply firewall rules to restrict access to TCP ports used for clustering (e.g., ports 4000, 4001, etc.) so that they are accessible only to other nodes within the WSO2 product cluster. Prevent access from unrecognized or external hosts.
24+
Apply firewall rules to restrict access to TCP ports used for clustering so that they are accessible only to other nodes within the WSO2 product cluster. Prevent access from unrecognized or external hosts.
25+
26+
!!! note
27+
The actual clustering ports depend on your product configuration. Verify the ports used in your deployment before configuring firewall rules.
1828

1929
## Use secure shell (SSH)
2030

@@ -34,4 +44,18 @@ Enable OS-level logging and review logs periodically to monitor user actions. Co
3444

3545
## Perform regular backups
3646

37-
Back up all the critical files and data regularly, and store them securely.
47+
Back up all critical files and data regularly, and store them securely.
48+
49+
Critical files to include in backups:
50+
51+
* Configuration files (e.g., `Config.toml`, environment-specific configurations)
52+
* Keystores and truststores
53+
* Database exports
54+
* Custom scripts and deployment artifacts
55+
56+
Backup recommendations:
57+
58+
* Perform daily backups for production environments
59+
* Store backups in encrypted, geographically-distributed storage
60+
* Test backup restoration procedures periodically
61+
* Implement access controls for backup storage

en/docs/deploy/deployment-best-practices/overview.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ Network security covers the infrastructure and network-level protections for you
2020

2121
[Learn more about network level security →](/deploy/deployment-best-practices/network-level-security)
2222

23+
## Configuration best practices
24+
25+
Adhering to secure configuration practices is essential for minimizing vulnerabilities in your BI deployment. This includes managing sensitive data, applying security patches, and following secure coding standards.
26+
27+
[Learn more about configuration best practices →](/deploy/deployment-best-practices/configuration-best-practices)
28+
2329
## Getting started
2430

2531
Review each category above to understand the security considerations for your deployment. Implement these practices based on your specific environment, compliance requirements, and security policies. These guidelines are applicable to both cloud-native (containerized) and traditional VM-based deployments.

0 commit comments

Comments
 (0)