Skip to content

Commit

Permalink
ci: config vpn
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Chiu <[email protected]>
  • Loading branch information
yangchiu committed May 25, 2024
1 parent 099c719 commit 2e4ef4b
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 0 deletions.
133 changes: 133 additions & 0 deletions pipelines/e2e/scripts/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
terraform {
required_providers {
rancher2 = {
source = "rancher/rancher2"
version = "3.0.0-rc2"
}
harvester = {
source = "harvester/harvester"
version = "0.6.1"
}
}
}

provider "rancher2" {
api_url = ""
insecure = true
access_key = ""
secret_key = ""
}

provider "harvester" {
kubeconfig = ""
}

data "harvester_network" "mgmt" {
name = "vlan104"
namespace = "longhorn-qa"
}

data "harvester_image" "ubuntu" {
display_name = "ubuntu-2204"
namespace = "longhorn-qa"
}

data "rancher2_cloud_credential" "credential" {
name = "test-cred-2"
}

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 = "I2Nsb3VkLWNvbmZpZwpwYWNrYWdlX3VwZGF0ZTogdHJ1ZQpwYWNrYWdlczoKICAtIHFlbXUtZ3Vlc3QtYWdlbnQKICAtIGlwdGFibGVzCnJ1bmNtZDoKICAtIC0gc3lzdGVtY3RsCiAgICAtIGVuYWJsZQogICAgLSAnLS1ub3cnCiAgICAtIHFlbXUtZ3Vlc3QtYWdlbnQuc2VydmljZQo="
}
}

resource "rancher2_cluster_v2" "test-cluster-0" {

name = "test-cluster-0"

kubernetes_version = "v1.27.13+rke2r1"

rke_config {
machine_pools {
name = "pool1"
cloud_credential_secret_name = data.rancher2_cloud_credential.credential.id
control_plane_role = true
etcd_role = true
worker_role = true
quantity = 1
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 = ""
}
}


#data "rancher2_cluster_v2" "cluster" {
# name = "test-cluster-2"
#}

output "output" {
value = data.harvester_network.mgmt
sensitive = "true"
}

output "output2" {
value = data.harvester_image.ubuntu
sensitive = "true"
}

output "cluster" {
value = rancher2_cluster_v2.test-cluster-0
sensitive = "true"
}
24 changes: 24 additions & 0 deletions pipelines/e2e/scripts/vpn
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

0 comments on commit 2e4ef4b

Please sign in to comment.