Skip to content

Commit 9f50108

Browse files
committed
Optimizing the handshake and test cloud
Signed-off-by: Shiming Zhang <[email protected]>
1 parent 002b532 commit 9f50108

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2235
-191
lines changed

.github/workflows/test-cloud.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Test Cloud
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
build-ferrctl:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.18
20+
21+
- run: |
22+
go build -o ferryctl ./cmd/ferryctl
23+
24+
- name: Upload ferryctl
25+
uses: actions/upload-artifact@v2
26+
with:
27+
name: ferryctl
28+
path: ferryctl
29+
30+
test-cloud:
31+
continue-on-error: true
32+
strategy:
33+
matrix:
34+
cloud:
35+
- aliyun
36+
- aws
37+
- azure
38+
- gcp
39+
runs-on: ubuntu-latest
40+
needs:
41+
- build-ferrctl
42+
steps:
43+
- uses: actions/checkout@v3
44+
45+
- name: Download for ferryctl
46+
uses: actions/download-artifact@v2
47+
with:
48+
name: ferryctl
49+
50+
- name: Set up ferryctl
51+
run: |
52+
cp ferryctl /usr/local/bin/ferryctl && chmod +x /usr/local/bin/ferryctl
53+
54+
- name: Set up eksctl
55+
if: matrix.cloud == 'aws'
56+
run: |
57+
wget -O eksctl.tar.gc "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_linux_amd64.tar.gz"
58+
tar -xzf eksctl.tar.gz -C /tmp/ && mv /tmp/eksctl /usr/local/bin/ && chmod +x /usr/local/bin/eksctl
59+
60+
- name: Set up gcloud
61+
if: matrix.cloud == 'gcp'
62+
uses: google-github-actions/setup-gcloud@v0
63+
with:
64+
install_components: 'gke-gcloud-auth-plugin'
65+
66+
- name: Login ${{ matrix.cloud }}
67+
run: |
68+
./test/cloud/${{ matrix.cloud }}/login.sh
69+
./test/cloud/${{ matrix.cloud }}/list.sh
70+
env:
71+
ALIYUN_ACCESS_KEY_ID: ${{ secrets.ALIYUN_ACCESS_KEY_ID }}
72+
ALIYUN_ACCESS_KEY_SECRET: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
73+
ALIYUN_REGION_ID: ${{ secrets.ALIYUN_REGION_ID }}
74+
ALIYUN_ZONE_ID: ${{ secrets.ALIYUN_ZONE_ID }}
75+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
76+
AWS_ACCESS_KEY_SECRET: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
77+
AWS_REGION_ID: ${{ secrets.AWS_REGION_ID }}
78+
AWS_ZONE_ID: ${{ secrets.AWS_ZONE_ID }}
79+
AZURE_APP_ID: ${{ secrets.AZURE_APP_ID }}
80+
AZURE_PASSWORD: ${{ secrets.AZURE_PASSWORD }}
81+
AZURE_TENANT: ${{ secrets.AZURE_TENANT }}
82+
AZURE_REGION_ID: ${{ secrets.AZURE_REGION_ID }}
83+
AZURE_ZONE_ID: ${{ secrets.AZURE_ZONE_ID }}
84+
GCP_CRED_DATA: ${{ secrets.GCP_CRED_DATA }}
85+
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
86+
GCP_REGION_ID: ${{ secrets.GCP_REGION_ID }}
87+
GCP_ZONE_ID: ${{ secrets.GCP_ZONE_ID }}
88+
- name: Start cluster
89+
run: |
90+
./test/hack/start-environment.sh cloud-${{ matrix.cloud }}
91+
92+
- name: Test control-plane and cluster-${{ matrix.cloud }}
93+
run: ./test/test/test-in-both-easy.sh
94+
env:
95+
ROUTE_NAME: ferry-test
96+
CONTROL_PLANE: control-plane
97+
CLUSTER_1: cluster-${{ matrix.cloud }}
98+
CLUSTER_2: control-plane
99+
TARGET_1: web-${{ matrix.cloud }}
100+
TARGET_2: web-0
101+
102+
- name: Clean cluster
103+
run: |
104+
./test/hack/clean-environment.sh cloud-${{ matrix.cloud }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
FERRY_TUNNEL_IMAGE: ferry-tunnel:test
1313

1414
concurrency:
15-
group: ${{ github.head_ref || github.run_id }}
15+
group: ${{ github.workflow }}-${{ github.ref }}
1616
cancel-in-progress: true
1717

1818
jobs:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ testbin/*
2222

2323

2424
# Customs
25+
!/test/bin
2526
vendor
26-
kubeconfigs
27+
test/kubeconfigs

pkg/ferryctl/cmd/ferryctl/control_plane/join/join.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ func NewCommand(logger log.Logger) *cobra.Command {
124124

125125
utils.Prompt(
126126
fmt.Sprintf("join the %s data cluster", dataPlaneName),
127-
"ferryctl data-plane init",
128127
next,
129128
)
130129

pkg/ferryctl/cmd/ferryctl/local/manual/export/export.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ func NewCommand(logger log.Logger) *cobra.Command {
9696

9797
utils.Prompt(
9898
"peer tunnel",
99-
"ferryctl data-plane init",
10099
second,
101100
)
102101
return nil

pkg/ferryctl/cmd/ferryctl/local/manual/import/import.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ func NewCommand(logger log.Logger) *cobra.Command {
104104

105105
utils.Prompt(
106106
"peer tunnel",
107-
"ferryctl data-plane init",
108107
second,
109108
)
110109
return nil

pkg/ferryctl/cmd/ferryctl/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func NewCommand(logger log.Logger) *cobra.Command {
4141

4242
persistentFlags := cmd.PersistentFlags()
4343
persistentFlags.StringVar(&vars.KubeconfigPath, "kubeconfig", vars.KubeconfigPath, "override the default kubeconfig path")
44+
persistentFlags.StringVar(&vars.PeerKubeconfigPath, "peer-kubeconfig", vars.PeerKubeconfigPath, "this Kubeconfig specifies the handshake peer for operations that require handshaking")
4445
persistentFlags.StringVar(&vars.FerryControllerImage, "ferry-controller-image", vars.FerryControllerImage, "default ferry controller image")
4546
persistentFlags.StringVar(&vars.FerryTunnelImage, "ferry-tunnel-image", vars.FerryTunnelImage, "default ferry tunnel image")
4647
persistentFlags.StringVar(&vars.ControlPlaneName, "control-plane-name", vars.ControlPlaneName, "default control plane name")

pkg/ferryctl/utils/prompt.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,34 @@ package utils
1818

1919
import (
2020
"fmt"
21+
"github.com/ferryproxy/ferry/pkg/ferryctl/vars"
22+
"os"
23+
"os/exec"
2124
)
2225

2326
func Prompt(want string, lines ...string) {
24-
fmt.Printf("# ++++ Please run the following command to %s:\n", want)
25-
fmt.Printf("# =============================================\n")
26-
defer fmt.Printf("# =============================================\n")
27-
for _, line := range lines {
28-
fmt.Printf("%s\n", line)
27+
if vars.PeerKubeconfigPath != "" {
28+
fmt.Printf("# Run command to %s:\n", want)
29+
for _, line := range lines {
30+
cmd := exec.Command("sh", "-c", line)
31+
cmd.Env = append(os.Environ(),
32+
"KUBECONFIG="+vars.PeerKubeconfigPath,
33+
"FERRY_PEER_KUBECONFIG="+vars.KubeconfigPath,
34+
)
35+
fmt.Printf("> %s\n", line)
36+
cmd.Stdout = os.Stdout
37+
cmd.Stderr = os.Stderr
38+
err := cmd.Run()
39+
if err != nil {
40+
fmt.Println(cmd)
41+
}
42+
}
43+
} else {
44+
fmt.Printf("# ++++ Please run the following command to %s:\n", want)
45+
fmt.Printf("# =============================================\n")
46+
defer fmt.Printf("# =============================================\n")
47+
for _, line := range lines {
48+
fmt.Printf("%s\n", line)
49+
}
2950
}
3051
}

pkg/ferryctl/vars/vars.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ import (
2525
)
2626

2727
var (
28-
ControlPlaneName = "control-plane"
29-
home, _ = os.UserHomeDir()
30-
KubeconfigPath = env.GetEnv("KUBECONFIG", filepath.Join(home, ".kube/config"))
28+
ControlPlaneName = "control-plane"
29+
home, _ = os.UserHomeDir()
30+
KubeconfigPath = env.GetEnv("KUBECONFIG", filepath.Join(home, ".kube/config"))
31+
PeerKubeconfigPath = env.GetEnv("FERRY_PEER_KUBECONFIG", "")
3132

3233
FerryImagePrefix = env.GetEnv("FERRY_IMAGE_PREFIX", "ghcr.io/ferryproxy/ferry")
3334

test/cloud/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Cloud
2+
3+
The following are the Kubernetes services for various public cloud platforms
4+
that Ferry has tested and validated. If there are multiple Kubernetes services
5+
on the same platform, we prefer to choose the one that does not require a management server.
6+
7+
- Aliyun (Alibaba Cloud)
8+
[ ] ACK (Managed Kubernetes Cluster Service)
9+
[x] ASK (Serverless Kubernetes Cluster Service)
10+
- AWS (Amazon Web Services)
11+
[x] EKS (Elastic Kubernetes Engine)
12+
- GCP (Google Cloud Platform)
13+
[ ] GKE Standard (Google Kubernetes Engine Standard)
14+
[x] GKE Autopilot (Google Kubernetes Engine Autopilot)
15+
- Azure (Microsoft Azure)
16+
[x] AKS (Azure Kubernets Service)
17+
18+
The following scripts are included in each platform's directory
19+
- login.sh `[This requires special handling, as each platform has a different login method]`
20+
- create.sh `<cluster-name>`
21+
- get_kubeconfig.sh` <cluster-name>`
22+
- list.sh
23+
- delete.sh `<cluster-name>`
24+
25+
## Login
26+
27+
### Aliyun
28+
ALIYUN_ACCESS_KEY_ID=
29+
ALIYUN_ACCESS_KEY_SECRET=
30+
ALIYUN_REGION_ID=
31+
ALIYUN_ZONE_ID=
32+
33+
### AWS
34+
AWS_ACCESS_KEY_ID=
35+
AWS_ACCESS_KEY_SECRET=
36+
AWS_REGION_ID=
37+
38+
### GCP
39+
GCP_PROJECT_ID=
40+
GCP_CRED_DATA=
41+
GCP_REGION_ID=
42+
43+
### Azure
44+
AZURE_APP_ID=
45+
AZURE_PASSWORD=
46+
AZURE_TENANT=
47+
AZURE_REGION_ID=

0 commit comments

Comments
 (0)