Skip to content

Commit 27ae3d7

Browse files
committed
Move skywalking cluster to a dedicated module and reorganize the doc
- Add workflow to generate and push doc.
1 parent d3f1b21 commit 27ae3d7

25 files changed

+800
-380
lines changed

.github/actions/terraform-docs

Submodule terraform-docs added at d1c9943

.github/workflows/documentation.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Check Docs
19+
on:
20+
- pull_request
21+
22+
jobs:
23+
docs:
24+
name: ${{ matrix.doc.name }}
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
doc:
29+
- name: AWS
30+
dir: aws
31+
output-file: configurations.md
32+
- name: AWS SkyWalking Module
33+
dir: aws/modules/skywalking
34+
output-file: README.md
35+
fail-fast: true
36+
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
submodules: true
40+
ref: ${{ github.event.pull_request.head.ref }}
41+
- name: Render and check docs is updated
42+
uses: ./.github/actions/terraform-docs
43+
with:
44+
working-dir: ${{ matrix.doc.dir }}
45+
output-file: ${{ matrix.doc.output-file }}
46+
output-method: inject
47+
fail-on-diff: "true"
48+
- name: Print diff
49+
if: ${{ failure() }}
50+
run: git diff --staged

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ ansible/local.var.yaml
1919
ansible/inventory
2020
!ansible/inventory/template
2121
.terraform.tfstate.lock.info
22+
terraform.tfvars

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule ".github/actions/terraform-docs"]
2+
path = .github/actions/terraform-docs
3+
url = https://github.com/terraform-docs/gh-actions.git

README.md

+17-191
Original file line numberDiff line numberDiff line change
@@ -1,200 +1,26 @@
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
142

153
For now, we have supported the following cloud vendors, and we welcome everyone to contribute supports for
164
more cloud vendors:
175

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.
1887

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.
19018
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:
19319

194-
```shell
195-
cd ../aws
196-
terraform output -raw alb_dns_name
197-
```
20+
# Ansible playbook for SkyWalking
19821

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.
20025

26+
Please go to the [ansible](ansible) folder for more details.

ansible/README.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
This guide provides steps on using Ansible to install Apache SkyWalking on VM instances.
2+
3+
# Prerequisites
4+
5+
- [Ansible installed](https://docs.ansible.com/ansible/latest/installation_guide/index.html).
6+
- A working knowledge of Ansible.
7+
- Access to instances.
8+
9+
# Instructions
10+
11+
## Change diroectory
12+
13+
```shell
14+
cd ansible
15+
```
16+
17+
## Test Connectivity to the Instances
18+
19+
Before installing SkyWalking, ensure that you can connect to the instances:
20+
21+
```shell
22+
ansible -m ping all
23+
```
24+
25+
**Expected Output**:
26+
27+
You should see output for each IP with a `SUCCESS` status:
28+
29+
```text
30+
<ip1> | SUCCESS => {
31+
"ansible_facts": {
32+
"discovered_interpreter_python": "/usr/bin/python3"
33+
},
34+
"changed": false,
35+
"ping": "pong"
36+
}
37+
<ip2> | SUCCESS => {
38+
"ansible_facts": {
39+
"discovered_interpreter_python": "/usr/bin/python3"
40+
},
41+
"changed": false,
42+
"ping": "pong"
43+
}
44+
```
45+
46+
## Install Apache SkyWalking
47+
48+
After confirming connectivity, proceed to install Apache SkyWalking using the Ansible playbook:
49+
50+
```
51+
ansible-playbook skywalking.yml
52+
```
53+
54+
## Configurations
55+
56+
The Ansible playbook can be customized to install Apache SkyWalking with
57+
different configurations. The following variables can be modified to suit your
58+
needs:
59+
60+
> For full configurations, refer to the
61+
> [roles/skywalking/vars/main.yml](roles/skywalking/vars/main.yml).
62+
> file.
63+
64+
```yaml
65+
# `skywalking_tarball` can be a remote URL or a local path, if it's a remote URL
66+
# the remote file will be downloaded to the remote host and then extracted,
67+
# if it's a local path, the local file will be copied to the remote host and
68+
# then extracted.
69+
skywalking_tarball: "https://dist.apache.org/repos/dist/release/skywalking/9.5.0/apache-skywalking-apm-9.5.0.tar.gz"
70+
71+
# `skywalking_ui_environment` is a dictionary of environment variables that will
72+
# be sourced when running the skywalking-ui service. All environment variables
73+
# that are supported by SkyWalking webapp can be set here.
74+
skywalking_ui_environment: {}
75+
76+
# `skywalking_oap_environment` is a dictionary of environment variables that will
77+
# be sourced when running the skywalking-oap service. All environment variables
78+
# that are supported by SkyWalking OAP can be set here.
79+
skywalking_oap_environment: {}
80+
81+
```
82+
83+
You can create a local variable file to override the default values:
84+
85+
```shell
86+
cat <<EOF > local.var.yaml
87+
skywalking_tarball: "~/workspace/skywalking/apm-dist/target/apache-skywalking-apm-bin.tar.gz"
88+
EOF
89+
```
90+
91+
And then run the playbook with the local variable file:
92+
93+
```shell
94+
ansible-playbook skywalking.yml -e @local.var.yaml
95+
```
96+
97+
## Accessing SkyWalking UI!
98+
99+
After the installation is complete, you can go back to the aws folder and get
100+
the ALB domain name address that can be used to access the SkyWalking UI:
101+
102+
```shell
103+
cd ../aws
104+
terraform output -raw alb_dns_name
105+
```
106+
107+
And you can open your browser and access the SkyWalking UI with the address.
108+

0 commit comments

Comments
 (0)