-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding e2e tests for shared vpc installs #1255
Open
barbacbd
wants to merge
1
commit into
kubernetes-sigs:main
Choose a base branch
from
barbacbd:add-shared-vpc-e2e-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,9 @@ EOF | |
|
||
# initialize a router and cloud NAT | ||
init_networks() { | ||
# gcloud compute shared-vpc enable "$GCP_PROJECT" | ||
# gcloud compute shared-vpc associated-projects add "$GCP_SERVICE_PROJECT" --host-project | ||
|
||
if [[ ${GCP_NETWORK_NAME} != "default" ]]; then | ||
gcloud compute networks create --project "$GCP_PROJECT" "${GCP_NETWORK_NAME}" --subnet-mode auto --quiet | ||
gcloud compute firewall-rules create "${GCP_NETWORK_NAME}"-allow-http --project "$GCP_PROJECT" \ | ||
|
@@ -125,7 +128,6 @@ init_networks() { | |
--nat-all-subnet-ip-ranges --auto-allocate-nat-external-ips | ||
} | ||
|
||
|
||
cleanup() { | ||
# Force a cleanup of cluster api created resources using gcloud commands | ||
(gcloud compute forwarding-rules list --project "$GCP_PROJECT" | grep capg-e2e \ | ||
|
@@ -143,25 +145,29 @@ cleanup() { | |
(gcloud compute instances list --project "$GCP_PROJECT" | grep capg-e2e \ | ||
| awk '{print "gcloud compute instances delete --project '"$GCP_PROJECT"' --quiet " $1 " --zone " $2 "\n"}' \ | ||
| bash) || true | ||
(gcloud compute instance-groups list --project "$GCP_PROJECT" | grep capg-e2e \ | ||
| awk '{print "gcloud compute instance-groups unmanaged delete --project '"$GCP_PROJECT"' --quiet " $1 " --zone " $2 "\n"}' \ | ||
| bash) || true | ||
(gcloud compute firewall-rules list --project "$GCP_PROJECT" | grep capg-e2e \ | ||
| awk '{print "gcloud compute firewall-rules delete --project '"$GCP_PROJECT"' --quiet " $1 "\n"}' \ | ||
| bash) || true | ||
(gcloud compute instance-groups list --project "$GCP_PROJECT" | grep capg-e2e \ | ||
| awk '{print "gcloud compute instance-groups unmanaged delete --project '"$GCP_PROJECT"' --quiet " $1 " --zone " $2 "\n"}' \ | ||
| bash) || true | ||
|
||
# cleanup the networks | ||
gcloud compute routers nats delete "${TEST_NAME}-mynat" --project="${GCP_PROJECT}" \ | ||
--router-region="${GCP_REGION}" --router="${TEST_NAME}-myrouter" --quiet || true | ||
gcloud compute routers delete "${TEST_NAME}-myrouter" --project="${GCP_PROJECT}" \ | ||
--region="${GCP_REGION}" --quiet || true | ||
|
||
if [[ ${GCP_NETWORK_NAME} != "default" ]]; then | ||
(gcloud compute firewall-rules list --project "$GCP_PROJECT" | grep "$GCP_NETWORK_NAME" \ | ||
| awk '{print "gcloud compute firewall-rules delete --project '"$GCP_PROJECT"' --quiet " $1 "\n"}' \ | ||
| bash) || true | ||
gcloud compute networks delete --project="${GCP_PROJECT}" \ | ||
--quiet "${GCP_NETWORK_NAME}" || true | ||
if [[ -n "${SKIP_INIT_NETWORK:-}" ]]; then | ||
echo "Skipping GCP network deletion..." | ||
else | ||
# cleanup the networks | ||
gcloud compute routers nats delete "${TEST_NAME}-mynat" --project="${GCP_PROJECT}" \ | ||
--router-region="${GCP_REGION}" --router="${TEST_NAME}-myrouter" --quiet || true | ||
gcloud compute routers delete "${TEST_NAME}-myrouter" --project="${GCP_PROJECT}" \ | ||
--region="${GCP_REGION}" --quiet || true | ||
|
||
if [[ ${GCP_NETWORK_NAME} != "default" ]]; then | ||
(gcloud compute firewall-rules list --project "$GCP_PROJECT" | grep "$GCP_NETWORK_NAME" \ | ||
| awk '{print "gcloud compute firewall-rules delete --project '"$GCP_PROJECT"' --quiet " $1 "\n"}' \ | ||
| bash) || true | ||
gcloud compute networks delete --project="${GCP_PROJECT}" \ | ||
--quiet "${GCP_NETWORK_NAME}" || true | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The GCP_SERVICE_PROJECT is where a lot of these resources such as image will be created during a shared vpc install. Trying to think of a way to incorporate that here on cleanup. |
||
fi | ||
|
||
if [[ -n "${SKIP_INIT_IMAGE:-}" ]]; then | ||
|
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
121 changes: 121 additions & 0 deletions
121
test/e2e/data/infrastructure-gcp/cluster-template-ci-with-shared-vpc.yaml
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,121 @@ | ||
--- | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: Cluster | ||
metadata: | ||
name: "${CLUSTER_NAME}" | ||
labels: | ||
cni: "${CLUSTER_NAME}-shared-vpc" | ||
spec: | ||
clusterNetwork: | ||
pods: | ||
cidrBlocks: ["192.168.0.0/16"] | ||
infrastructureRef: | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 | ||
kind: GCPCluster | ||
name: "${CLUSTER_NAME}" | ||
controlPlaneRef: | ||
kind: KubeadmControlPlane | ||
apiVersion: controlplane.cluster.x-k8s.io/v1beta1 | ||
name: "${CLUSTER_NAME}-control-plane" | ||
--- | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 | ||
kind: GCPCluster | ||
metadata: | ||
name: "${CLUSTER_NAME}" | ||
spec: | ||
project: "${GCP_SERVICE_PROJECT}" | ||
region: "${GCP_REGION}" | ||
network: | ||
name: "${GCP_NETWORK_NAME}" | ||
hostProject: "${GCP_PROJECT}" | ||
--- | ||
apiVersion: controlplane.cluster.x-k8s.io/v1beta1 | ||
kind: KubeadmControlPlane | ||
metadata: | ||
name: "${CLUSTER_NAME}-control-plane" | ||
spec: | ||
replicas: ${CONTROL_PLANE_MACHINE_COUNT} | ||
machineTemplate: | ||
infrastructureRef: | ||
kind: GCPMachineTemplate | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 | ||
name: "${CLUSTER_NAME}-control-plane" | ||
kubeadmConfigSpec: | ||
useExperimentalRetryJoin: true | ||
initConfiguration: | ||
nodeRegistration: | ||
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}' | ||
kubeletExtraArgs: | ||
cloud-provider: gce | ||
clusterConfiguration: | ||
apiServer: | ||
timeoutForControlPlane: 20m | ||
extraArgs: | ||
cloud-provider: gce | ||
controllerManager: | ||
extraArgs: | ||
cloud-provider: gce | ||
allocate-node-cidrs: "false" | ||
kubernetesVersion: "${KUBERNETES_VERSION}" | ||
joinConfiguration: | ||
nodeRegistration: | ||
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}' | ||
kubeletExtraArgs: | ||
cloud-provider: gce | ||
version: "${KUBERNETES_VERSION}" | ||
--- | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 | ||
kind: GCPMachineTemplate | ||
metadata: | ||
name: "${CLUSTER_NAME}-control-plane" | ||
spec: | ||
template: | ||
spec: | ||
instanceType: "${GCP_CONTROL_PLANE_MACHINE_TYPE}" | ||
image: "${IMAGE_ID}" | ||
--- | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: MachineDeployment | ||
metadata: | ||
name: "${CLUSTER_NAME}-md-0" | ||
spec: | ||
clusterName: "${CLUSTER_NAME}" | ||
replicas: ${WORKER_MACHINE_COUNT} | ||
selector: | ||
matchLabels: | ||
template: | ||
spec: | ||
clusterName: "${CLUSTER_NAME}" | ||
version: "${KUBERNETES_VERSION}" | ||
bootstrap: | ||
configRef: | ||
name: "${CLUSTER_NAME}-md-0" | ||
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 | ||
kind: KubeadmConfigTemplate | ||
infrastructureRef: | ||
name: "${CLUSTER_NAME}-md-0" | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 | ||
kind: GCPMachineTemplate | ||
--- | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 | ||
kind: GCPMachineTemplate | ||
metadata: | ||
name: "${CLUSTER_NAME}-md-0" | ||
spec: | ||
template: | ||
spec: | ||
instanceType: "${GCP_NODE_MACHINE_TYPE}" | ||
image: "${IMAGE_ID}" | ||
--- | ||
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 | ||
kind: KubeadmConfigTemplate | ||
metadata: | ||
name: "${CLUSTER_NAME}-md-0" | ||
spec: | ||
template: | ||
spec: | ||
joinConfiguration: | ||
nodeRegistration: | ||
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}' | ||
kubeletExtraArgs: | ||
cloud-provider: gce |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These actions require more permissions. We either need to allow this permission, setup a specific project just for this e2e test, or use the same project (which wont be a shared vpc install). Any ideas @damdo ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what's best here. @cpanato did this ever come up in the past?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if need another project to run together, i would suggest to we talk with sig-testing/sig-infra to see if that is possible when running the prow job