Skip to content

Commit

Permalink
Merge remote-tracking branch 'twz123/ostests-add-kube-proxy-mode' int…
Browse files Browse the repository at this point in the history
…o tmp-test

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Sep 19, 2023
2 parents 6c8cf9a + da6016c commit aba09e4
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ostests-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ on:
type: string
description: The k0s network provider to test.
required: true
kube-proxy-mode:
type: string
description: The k0s kube-proxy mode to test.
required: true
terraform-version:
type: string
description: The Terraform version to use when provisioning test resources.
Expand Down Expand Up @@ -64,6 +68,7 @@ jobs:
TF_VAR_k0s_version: ${{ inputs.k0s-version }}
TF_VAR_k0sctl_executable_path: ${{ github.workspace }}/.cache/k0sctl
TF_VAR_k0s_network_provider: ${{ inputs.network-provider }}
TF_VAR_k0s_kube_proxy_mode: ${{ inputs.kube-proxy-mode }}

defaults:
run:
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/ostests-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ on:
"kuberouter",
"calico"
]
kube-proxy-modes:
type: string
description: The k0s kube-proxy modes to test.
required: true
default: >-
[
"iptables",
"ipvs"
]
jobs:
build:
Expand All @@ -56,8 +65,9 @@ jobs:
matrix:
os: ${{ fromJSON(github.event.inputs.oses) }}
network-provider: ${{ fromJSON(github.event.inputs.network-providers) }}
kube-proxy-mode: ${{ fromJSON(github.event.inputs.kube-proxy-modes) }}

name: "${{ matrix.os }} :: ${{ matrix.network-provider }}"
name: "${{ matrix.os }} :: ${{ matrix.network-provider }} :: ${{ matrix.kube-proxy-mode }}"
needs: build
if: always() && (inputs.k0s-version != '' || needs.build.result == 'success')
uses: ./.github/workflows/ostests-e2e.yaml
Expand All @@ -67,6 +77,7 @@ jobs:
e2e-focus: ${{ inputs.e2e-focus }}
os: ${{ matrix.os }}
network-provider: ${{ matrix.network-provider }}
kube-proxy-mode: ${{ matrix.kube-proxy-mode }}
secrets:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/ostests-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ env:
"kuberouter",
"calico"
]
KUBE_PROXY_MODES: >-
[
"iptables",
"ipvs"
]
jobs:
select:
Expand All @@ -49,13 +54,14 @@ jobs:
script: |
const distros = JSON.parse(process.env.DISTRIBUTIONS)
const networkProviders = JSON.parse(process.env.NETWORK_PROVIDERS)
const kubeProxyModes = JSON.parse(process.env.KUBE_PROXY_MODES)
const oses = []
for (let i = 0; ; i++) {
let added = false
for (const distro of distros) {
if (i < distro.length) {
oses.push(distro[i]);
oses.push(distro[i])
added = true
}
}
Expand All @@ -65,17 +71,25 @@ jobs:
}
const combinations = []
for (const [i, _] of networkProviders.entries()) {
for (const [j, os] of oses.entries()) {
combinations.push([os, networkProviders[(i + j) % networkProviders.length]])
for (const [kpmIdx, _] of kubeProxyModes.entries()) {
for (const [npIdx, _] of networkProviders.entries()) {
for (const [osIdx, os] of oses.entries()) {
combinations.push([
os,
networkProviders[(npIdx + osIdx) % networkProviders.length],
kubeProxyModes[(kpmIdx + osIdx) % kubeProxyModes.length],
])
}
}
}
const daysSinceEpoch = Math.floor(Date.now() / (24 * 60 * 60 * 1000))
const [os, networkProvider] = combinations[daysSinceEpoch % combinations.length]
const [os, networkProvider, kubeProxyMode] =
combinations[daysSinceEpoch % combinations.length]
console.log(`Selected ${os}/${networkProvider}`)
core.setOutput('os', os)
core.setOutput('network-provider', networkProvider)
core.setOutput('kube-proxy-mode', kubeProxyMode)
build:
name: Build
Expand Down
6 changes: 6 additions & 0 deletions hack/ostests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ other ways described [here][tf-config].
export TF_VAR_os=alpine_3_17
export TF_VAR_k0s_version=stable
export TF_VAR_k0s_network_provider=calico
export TF_VAR_k0s_kube_proxy_mode=ipvs
```

[aws-config]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
Expand Down Expand Up @@ -97,6 +98,11 @@ This may be a fixed version number, "stable" or "latest".
* `kuberouter`
* `calico`

### `k0s_kube_proxy_mode`: Network provider

* `iptables`
* `ipvs`

### Adding a new operating system

* Navigate to [modules/os/](modules/os/) and add a new file `os_<the-os-id>.tf`.
Expand Down
6 changes: 6 additions & 0 deletions hack/ostests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ provider "aws" {
"ostests.k0sproject.io/instance" = local.resource_name_prefix
"ostests.k0sproject.io/os" = var.os
"ostests.k0sproject.io/k0s-network-provider" = var.k0s_network_provider
"ostests.k0sproject.io/k0s-kube-proxy-mode" = var.k0s_kube_proxy_mode
})
}
}
Expand Down Expand Up @@ -50,6 +51,11 @@ module "k0sctl" {
network = {
provider = var.k0s_network_provider
podCIDR = local.podCIDR

kubeProxy = {
mode = var.k0s_kube_proxy_mode
}

nodeLocalLoadBalancing = {
enabled = true
}
Expand Down
3 changes: 3 additions & 0 deletions hack/ostests/modules/k0sctl/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ variable "k0s_config_spec" {
network = optional(object({
provider = optional(string),
podCIDR = optional(string),
kubeProxy = optional(object({
mode = string,
}))
nodeLocalLoadBalancing = optional(object({
enabled = optional(bool),
})),
Expand Down
11 changes: 11 additions & 0 deletions hack/ostests/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,14 @@ variable "k0s_network_provider" {
error_message = "Unsupported k0s CNI stack."
}
}

variable "k0s_kube_proxy_mode" {
type = string
description = "The k0s kube-proxy mode to use (either iptables or ipvs)."
default = "iptables"

validation {
condition = var.k0s_kube_proxy_mode == "iptables" || var.k0s_kube_proxy_mode == "ipvs"
error_message = "Unsupported k0s kube-proxy mode."
}
}

0 comments on commit aba09e4

Please sign in to comment.