|
1 |
| -# SkyWalking Terraform and Ansible |
2 |
| - |
3 |
| -This repository contains the Terraform scripts to create the infrastructure for SkyWalking on cloud vendors, |
4 |
| -and the Ansible playbooks to install SkyWalking on the created infrastructure, or on the existing infrastructure, |
5 |
| -no matter on-premises or on cloud vendors, such as AWS. |
6 |
| - |
7 |
| -# Terraform |
8 |
| - |
9 |
| -**Notice, HashiCorp had changed the LICENSE of Terraform from MPL 2.0 to BSL/BUSL 1.1 since its 1.5.6 release. We don't have hard-dependencies on Terraform.** |
10 |
| - |
11 |
| -**OpenTF Foundation announced to maintain the MPL 2.0 based fork of Terraform. Read their [announcement](https://opentf.org/announcement) and [website](https://opentf.org/) for more details.** |
12 |
| - |
13 |
| -**All Terraform and/or OpenTF scripts are just for end-user convenience. The Apache 2.0 License is only for the scripts.** |
| 1 | +# Terraform module for SkyWalking |
14 | 2 |
|
15 | 3 | For now, we have supported the following cloud vendors, and we welcome everyone to contribute supports for
|
16 | 4 | more cloud vendors:
|
17 | 5 |
|
18 |
| -- Amazon Web Services (AWS): go to the [aws](aws) folder for more details. |
19 |
| - |
20 |
| -## Prerequisites |
21 |
| - |
22 |
| -1. Terraform installed |
23 |
| -2. AWS Credentials: Ensure your environment is set up with the necessary AWS credentials. This can be done in various ways, such as: |
24 |
| - - Configuring using the AWS CLI. |
25 |
| - - Setting up environment variables (`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`). |
26 |
| - - Using IAM roles with necessary permissions if you're running Terraform on an AWS EC2 instance. |
27 |
| - - For more information on configuring AWS credentials for Terraform, see the [official documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#authentication-and-configuration). |
28 |
| -3. A working knowledge of Terraform and AWS resources |
29 |
| - |
30 |
| -## Instructions |
31 |
| - |
32 |
| -### 1. Initialization |
33 |
| - |
34 |
| -Before applying any Terraform script, initialize your Terraform working directory: |
35 |
| - |
36 |
| -```bash |
37 |
| -cd aws/ |
38 |
| -terraform init |
39 |
| -``` |
40 |
| - |
41 |
| -### 2. Configuration |
42 |
| - |
43 |
| -The script is designed with modularity and reusability in mind. Various parameters like region, instance count, instance type, etc., are exposed as variables for easier customization. |
44 |
| - |
45 |
| -For the full configuration list, please refer to [the doc](/aws/README.md). |
46 |
| - |
47 |
| -To modify the default values, you can create a `terraform.tfvars` file in the same directory as your Terraform script: |
48 |
| - |
49 |
| -```bash |
50 |
| -oap_instance_count = 2 |
51 |
| -ui_instance_count = 2 |
52 |
| -region = "us-west-1" |
53 |
| -instance_type = "t2.large" |
54 |
| -extra_tags = { |
55 |
| - "Environment" = "Production" |
56 |
| -} |
57 |
| -``` |
58 |
| - |
59 |
| -### 3. Test and apply the outcomes of the Script |
60 |
| - |
61 |
| -After adjusting your configuration, test and apply the script: |
62 |
| - |
63 |
| -```bash |
64 |
| -terraform plan |
65 |
| -terraform apply |
66 |
| -``` |
67 |
| - |
68 |
| -After all the resources are created, you can head to the |
69 |
| -[Ansible part](#ansible) to start deploying SkyWalking. |
70 |
| - |
71 |
| -### 4. Accessing the Resources |
72 |
| - |
73 |
| -#### SSH into bastion host (Optional) |
74 |
| - |
75 |
| -You don't usually need to SSH into the bastion host, but if you want to, you can |
76 |
| -SSH into the bastion host with the command: |
77 |
| - |
78 |
| -```shell |
79 |
| -KEY_FILE=$(terraform output -raw ssh-user-key-file) |
80 |
| -BASTION_IP=$(terraform output -json bastion_ips | jq -r '.[0]') |
81 |
| - |
82 |
| -ssh -i "$KEY_FILE" ec2-user@"$BASTION_IP" |
83 |
| -``` |
84 |
| - |
85 |
| -- **Security Attention**: two security rules are created for the bastion host: |
86 |
| - - `ssh-access`: Allows SSH access from any IP (`0.0.0.0/0`). **Please note** that this is potentially insecure and you should restrict the IP range wherever possible. |
87 |
| - - `public-egress-access`: Allows egress access to the internet for the instances. |
88 |
| - |
89 |
| -### 5. Tearing Down |
90 |
| - |
91 |
| -To destroy the resources when they are no longer needed: |
92 |
| - |
93 |
| -```bash |
94 |
| -terraform destroy |
95 |
| -``` |
96 |
| - |
97 |
| -This command will prompt you to confirm before destroying the resources. |
98 |
| - |
99 |
| -## Security Note |
100 |
| - |
101 |
| -SSH access is open to the entire internet (`0.0.0.0/0`). This is not recommended for production environments. Always restrict the CIDR block to known IP ranges for better security. |
102 |
| - |
103 |
| -# Ansible |
104 |
| - |
105 |
| -You can use the Ansible playbook in combination with the Terraform to create necessary infrastructure and install |
106 |
| -SkyWalking on the created infrastructure, or you can use the Ansible to install SkyWalking on the existing infrastructure. |
107 |
| - |
108 |
| -This guide provides steps on using Ansible to install Apache SkyWalking on AWS instances. |
109 |
| - |
110 |
| -## Prerequisites |
111 |
| - |
112 |
| -1. Ansible installed. |
113 |
| -2. A working knowledge of Ansible and AWS resources. |
114 |
| -3. An active SSH key and access to AWS EC2 instances. |
115 |
| - |
116 |
| -## Instructions |
117 |
| - |
118 |
| -### 1. Change diroectory |
119 |
| - |
120 |
| -```shell |
121 |
| -cd ../ansible/ |
122 |
| -``` |
123 |
| - |
124 |
| -### 2. Test Connectivity to the EC2 Instances |
125 |
| - |
126 |
| -Before installing SkyWalking, ensure that you can connect to the EC2 instances: |
127 |
| - |
128 |
| -``` |
129 |
| -ansible -m ping all -u ec2-user |
130 |
| -``` |
131 |
| - |
132 |
| -**Expected Output**: |
133 |
| - |
134 |
| -You should see output for each IP with a `SUCCESS` status: |
135 |
| -```text |
136 |
| -<ip1> | SUCCESS => { |
137 |
| - "ansible_facts": { |
138 |
| - "discovered_interpreter_python": "/usr/bin/python3" |
139 |
| - }, |
140 |
| - "changed": false, |
141 |
| - "ping": "pong" |
142 |
| -} |
143 |
| -<ip2> | SUCCESS => { |
144 |
| - "ansible_facts": { |
145 |
| - "discovered_interpreter_python": "/usr/bin/python3" |
146 |
| - }, |
147 |
| - "changed": false, |
148 |
| - "ping": "pong" |
149 |
| -} |
150 |
| -``` |
151 |
| - |
152 |
| -### 3. Install Apache SkyWalking |
153 |
| - |
154 |
| -After confirming connectivity, proceed to install Apache SkyWalking using the Ansible playbook: |
155 |
| - |
156 |
| -``` |
157 |
| -ansible-playbook skywalking.yml |
158 |
| -``` |
159 |
| - |
160 |
| -### 4. Configurations |
161 |
| - |
162 |
| -The Ansible playbook can be customized to install Apache SkyWalking with |
163 |
| -different configurations. The following variables can be modified to suit your |
164 |
| -needs: |
165 |
| - |
166 |
| -> For full configurations, refer to the |
167 |
| -> [ansible/roles/skywalking/vars/main.yml](ansible/roles/skywalking/vars/main.yml). |
168 |
| -> file. |
169 |
| -
|
170 |
| -```yaml |
171 |
| -# `skywalking_tarball` can be a remote URL or a local path, if it's a remote URL |
172 |
| -# the remote file will be downloaded to the remote host and then extracted, |
173 |
| -# if it's a local path, the local file will be copied to the remote host and |
174 |
| -# then extracted. |
175 |
| -skywalking_tarball: "https://dist.apache.org/repos/dist/release/skywalking/9.5.0/apache-skywalking-apm-9.5.0.tar.gz" |
176 |
| - |
177 |
| -# `skywalking_ui_environment` is a dictionary of environment variables that will |
178 |
| -# be sourced when running the skywalking-ui service. All environment variables |
179 |
| -# that are supported by SkyWalking webapp can be set here. |
180 |
| -skywalking_ui_environment: {} |
181 |
| - |
182 |
| -# `skywalking_oap_environment` is a dictionary of environment variables that will |
183 |
| -# be sourced when running the skywalking-oap service. All environment variables |
184 |
| -# that are supported by SkyWalking OAP can be set here. |
185 |
| -skywalking_oap_environment: {} |
186 |
| - |
187 |
| -``` |
| 6 | +- [AWS](aws): Terraform scripts to provision necessary resources on Amazon Web Services. |
188 | 7 |
|
189 |
| -### 5. Accessing SkyWalking UI! |
| 8 | +> [!NOTE] |
| 9 | +> HashiCorp had changed the LICENSE of Terraform from MPL 2.0 to BSL/BUSL 1.1 |
| 10 | +> since its 1.5.6 release. We don't have hard-dependencies on Terraform. |
| 11 | +> |
| 12 | +> OpenTF Foundation announced to maintain the MPL 2.0 based fork of Terraform. |
| 13 | +> Read their [announcement](https://opentf.org/announcement) and |
| 14 | +> [website](https://opentf.org/) for more details. |
| 15 | +> |
| 16 | +> All Terraform and/or OpenTF scripts are just for end-user convenience. |
| 17 | +> The Apache 2.0 License is only for the scripts. |
190 | 18 |
|
191 |
| -After the installation is complete, you can go back to the aws folder and get |
192 |
| -the ALB domain name address that can be used to access the SkyWalking UI: |
193 | 19 |
|
194 |
| -```shell |
195 |
| -cd ../aws |
196 |
| -terraform output -raw alb_dns_name |
197 |
| -``` |
| 20 | +# Ansible playbook for SkyWalking |
198 | 21 |
|
199 |
| -And you can open your browser and access the SkyWalking UI with the address. |
| 22 | +You can use the Ansible playbook in combination with the Terraform to create |
| 23 | +necessary infrastructure and install SkyWalking on the created infrastructure, |
| 24 | +or you can use the Ansible to install SkyWalking on the existing infrastructure. |
200 | 25 |
|
| 26 | +Please go to the [ansible](ansible) folder for more details. |
0 commit comments