forked from longhorn/longhorn-tests
-
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.
Signed-off-by: Yang Chiu <[email protected]>
- Loading branch information
Showing
11 changed files
with
401 additions
and
12 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
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
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,135 @@ | ||
terraform { | ||
required_providers { | ||
rancher2 = { | ||
source = "rancher/rancher2" | ||
version = "3.0.0-rc2" | ||
} | ||
} | ||
} | ||
|
||
provider "rancher2" { | ||
api_url = "" | ||
insecure = true | ||
access_key = "" | ||
secret_key = "" | ||
} | ||
|
||
data "rancher2_cluster_v2" "hal-cluster" { | ||
name = "hal" | ||
} | ||
|
||
resource "rancher2_cloud_credential" "credential" { | ||
name = "test-credential" | ||
harvester_credential_config { | ||
cluster_id = data.rancher2_cluster_v2.hal-cluster.cluster_v1_id | ||
cluster_type = "imported" | ||
kubeconfig_content = data.rancher2_cluster_v2.hal-cluster.kube_config | ||
} | ||
} | ||
|
||
resource "rancher2_machine_config_v2" "test-machine-config" { | ||
|
||
generate_name = "test-machine-config" | ||
|
||
harvester_config { | ||
|
||
vm_namespace = "longhorn-qa" | ||
|
||
cpu_count = "4" | ||
memory_size = "8" | ||
|
||
disk_info = <<EOF | ||
{ | ||
"disks": [{ | ||
"imageName": "longhorn-qa/image-nbv7f", | ||
"size": 100, | ||
"bootOrder": 1 | ||
}] | ||
} | ||
EOF | ||
|
||
network_info = <<EOF | ||
{ | ||
"interfaces": [{ | ||
"networkName": "longhorn-qa/vlan104" | ||
}] | ||
} | ||
EOF | ||
|
||
ssh_user = "ubuntu" | ||
|
||
user_data = <<EOF | ||
#cloud-config | ||
ssh_authorized_keys: | ||
- >- | ||
ssh-rsa | ||
package_update: true | ||
packages: | ||
- qemu-guest-agent | ||
- iptables | ||
runcmd: | ||
- - systemctl | ||
- enable | ||
- '--now' | ||
- qemu-guest-agent.service | ||
EOF | ||
} | ||
} | ||
|
||
resource "rancher2_cluster_v2" "test-cluster-0" { | ||
|
||
name = "test-cluster-0" | ||
|
||
kubernetes_version = "v1.27.13+rke2r1" | ||
|
||
rke_config { | ||
machine_pools { | ||
name = "control-plane-pool" | ||
cloud_credential_secret_name = rancher2_cloud_credential.credential.id | ||
control_plane_role = true | ||
etcd_role = true | ||
worker_role = false | ||
quantity = 1 | ||
machine_config { | ||
kind = rancher2_machine_config_v2.test-machine-config.kind | ||
name = rancher2_machine_config_v2.test-machine-config.name | ||
} | ||
} | ||
machine_pools { | ||
name = "worker-pool" | ||
cloud_credential_secret_name = rancher2_cloud_credential.credential.id | ||
control_plane_role = false | ||
etcd_role = false | ||
worker_role = true | ||
quantity = 3 | ||
machine_config { | ||
kind = rancher2_machine_config_v2.test-machine-config.kind | ||
name = rancher2_machine_config_v2.test-machine-config.name | ||
} | ||
} | ||
machine_selector_config { | ||
config = { | ||
cloud-provider-name = "" | ||
} | ||
} | ||
machine_global_config = <<EOF | ||
cni: "calico" | ||
disable-kube-proxy: false | ||
etcd-expose-metrics: false | ||
EOF | ||
upgrade_strategy { | ||
control_plane_concurrency = "10%" | ||
worker_concurrency = "10%" | ||
} | ||
etcd { | ||
snapshot_schedule_cron = "0 */5 * * *" | ||
snapshot_retention = 5 | ||
} | ||
chart_values = "" | ||
} | ||
} | ||
|
||
output "cluster" { | ||
value = rancher2_cluster_v2.test-cluster-0.kube_config | ||
sensitive = "true" | ||
} |
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,24 @@ | ||
$ docker run --cap-add=NET_ADMIN -it alpine /bin/sh | ||
/ # history | ||
0 apk add openvpn | ||
1 mkdir -p /dev/net | ||
2 mknod /dev/net/tun c 10 200 | ||
3 chmod 600 /dev/net/tun | ||
4 vi vpn.ovpn | ||
# | ||
script-security 2 | ||
up /etc/openvpn/up.sh | ||
down /etc/openvpn/down.sh | ||
# | ||
5 vi login.conf | ||
6 openvpn --config vpn.ovpn | ||
7 openvpn --config vpn.ovpn --daemon | ||
8 ps aux | ||
9 cat /etc/resolv.conf | ||
10 wget url | ||
14 traceroute url | ||
20 vi kubeconfig | ||
23 wget -q https://storage.googleapis.com/kubernetes-release/release/v1.30.0/bin/linux/amd64/kubectl | ||
24 mv kubectl /usr/local/bin/kubectl | ||
25 chmod +x /usr/local/bin/kubectl | ||
29 export KUBECONFIG=/kubeconfig |
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
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
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
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
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 @@ | ||
connect_to_vpn(){ | ||
mkdir -p /dev/net | ||
mknod /dev/net/tun c 10 200 | ||
chmod 600 /dev/net/tun | ||
openvpn --config vpn.ovpn --daemon | ||
sleep 10 | ||
cat /var/log/openvpn.log | ||
} |
Oops, something went wrong.