Skip to content

Commit

Permalink
Introduce externalMethod=WholeIP for VMs (#616)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Kvapil <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new configuration option for specifying the method to
handle external traffic. Users can now choose between "WholeIP" and
"PortList" (default) across virtual machine and instance deployments.
- Service settings now adjust automatically based on the selected
external traffic method.

- **Documentation**
- Updated configuration guides to include details on the new
`externalMethod` parameter and its usage for managing external traffic.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Andrei Kvapil <[email protected]>
  • Loading branch information
kvaps authored Feb 7, 2025
1 parent 1a88883 commit f768dc1
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 18 deletions.
6 changes: 4 additions & 2 deletions packages/apps/versions_map
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ virtual-machine 0.4.0 4746d51
virtual-machine 0.5.0 cad9cde
virtual-machine 0.6.0 0e728870
virtual-machine 0.7.0 af58018a
virtual-machine 0.7.1 HEAD
virtual-machine 0.7.1 05857b95
virtual-machine 0.8.0 HEAD
vm-disk 0.1.0 HEAD
vm-instance 0.1.0 ced8e5b9
vm-instance 0.2.0 4f767ee3
vm-instance 0.3.0 0e728870
vm-instance 0.4.0 af58018a
vm-instance 0.4.1 HEAD
vm-instance 0.4.1 05857b95
vm-instance 0.5.0 HEAD
vpn 0.1.0 f642698
vpn 0.2.0 7151424
vpn 0.3.0 a2bcf100
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/virtual-machine/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.7.1
version: 0.8.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.7.1"
appVersion: "0.8.0"
1 change: 1 addition & 0 deletions packages/apps/virtual-machine/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ generate:
&& yq -i -o json ".properties.instanceProfile.optional=true | .properties.instanceProfile.enum = $${PREFERENCES}" values.schema.json
yq -i -o json '.properties.externalPorts.items.type = "integer"' values.schema.json
yq -i -o json '.properties.systemDisk.properties.image.enum = ["ubuntu", "cirros", "alpine", "fedora", "talos"]' values.schema.json
yq -i -o json '.properties.externalMethod.enum = ["wholeIP", "PortList"]' values.schema.json
1 change: 1 addition & 0 deletions packages/apps/virtual-machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ virtctl ssh <user>@<vm>
| Name | Description | Value |
| ------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------- |
| `external` | Enable external access from outside the cluster | `false` |
| `externalMethod` | specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList` | `WholeIP` |
| `externalPorts` | Specify ports to forward from outside the cluster | `[]` |
| `running` | Determines if the virtual machine should be running | `true` |
| `instanceType` | Virtual Machine instance type | `u1.medium` |
Expand Down
8 changes: 8 additions & 0 deletions packages/apps/virtual-machine/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ metadata:
name: {{ include "virtual-machine.fullname" . }}
labels:
{{- include "virtual-machine.labels" . | nindent 4 }}
{{- if eq .Values.externalMethod "WholeIP" }}
annotations:
networking.cozystack.io/wholeIP: "true"
{{- end }}
spec:
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
externalTrafficPolicy: Local
allocateLoadBalancerNodePorts: false
selector:
{{- include "virtual-machine.labels" . | nindent 4 }}
ports:
{{- if eq .Values.externalMethod "WholeIP" }}
- port: 65535
{{- else }}
{{- range .Values.externalPorts }}
- name: port-{{ . }}
port: {{ . }}
targetPort: {{ . }}
{{- end }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions packages/apps/virtual-machine/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"description": "Enable external access from outside the cluster",
"default": false
},
"externalMethod": {
"type": "string",
"description": "specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList`",
"default": "WholeIP",
"enum": [
"wholeIP",
"PortList"
]
},
"externalPorts": {
"type": "array",
"description": "Specify ports to forward from outside the cluster",
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/virtual-machine/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## @section Common parameters

## @param external Enable external access from outside the cluster
## @param externalMethod specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList`
## @param externalPorts [array] Specify ports to forward from outside the cluster
external: false
externalMethod: WholeIP
externalPorts:
- 22

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/vm-instance/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.4.1
version: 0.5.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.4.1"
appVersion: "0.5.0"
1 change: 1 addition & 0 deletions packages/apps/vm-instance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ generate:
PREFERENCES=$$(yq e '.metadata.name' -o=json -r ../../system/kubevirt-instancetypes/templates/preferences.yaml | yq 'split(" ") | . + [""]' -o json) \
&& yq -i -o json ".properties.instanceProfile.optional=true | .properties.instanceProfile.enum = $${PREFERENCES}" values.schema.json
yq -i -o json '.properties.externalPorts.items.type = "integer"' values.schema.json
yq -i -o json '.properties.externalMethod.enum = ["WholeIP", "PortList"]' values.schema.json
25 changes: 13 additions & 12 deletions packages/apps/vm-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ virtctl ssh <user>@<vm>

### Common parameters

| Name | Description | Value |
| ------------------ | ---------------------------------------------------------------------------------- | ---------------- |
| `external` | Enable external access from outside the cluster | `false` |
| `externalPorts` | Specify ports to forward from outside the cluster | `[]` |
| `running` | Determines if the virtual machine should be running | `true` |
| `instanceType` | Virtual Machine instance type | `u1.medium` |
| `instanceProfile` | Virtual Machine prefferences profile | `ubuntu` |
| `disks` | List of disks to attach | `[]` |
| `resources.cpu` | The number of CPU cores allocated to the virtual machine | `""` |
| `resources.memory` | The amount of memory allocated to the virtual machine | `""` |
| `sshKeys` | List of SSH public keys for authentication. Can be a single key or a list of keys. | `[]` |
| `cloudInit` | cloud-init user data config. See cloud-init documentation for more details. | `#cloud-config
| Name | Description | Value |
| ------------------ | ---------------------------------------------------------------------------------------------------------- | ---------------- |
| `external` | Enable external access from outside the cluster | `false` |
| `externalMethod` | specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList` | `WholeIP` |
| `externalPorts` | Specify ports to forward from outside the cluster | `[]` |
| `running` | Determines if the virtual machine should be running | `true` |
| `instanceType` | Virtual Machine instance type | `u1.medium` |
| `instanceProfile` | Virtual Machine prefferences profile | `ubuntu` |
| `disks` | List of disks to attach | `[]` |
| `resources.cpu` | The number of CPU cores allocated to the virtual machine | `""` |
| `resources.memory` | The amount of memory allocated to the virtual machine | `""` |
| `sshKeys` | List of SSH public keys for authentication. Can be a single key or a list of keys. | `[]` |
| `cloudInit` | cloud-init user data config. See cloud-init documentation for more details. | `#cloud-config
` |

## U Series
Expand Down
8 changes: 8 additions & 0 deletions packages/apps/vm-instance/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ metadata:
name: {{ include "virtual-machine.fullname" . }}
labels:
{{- include "virtual-machine.labels" . | nindent 4 }}
{{- if eq .Values.externalMethod "WholeIP" }}
annotations:
networking.cozystack.io/wholeIP: "true"
{{- end }}
spec:
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
externalTrafficPolicy: Local
allocateLoadBalancerNodePorts: false
selector:
{{- include "virtual-machine.labels" . | nindent 4 }}
ports:
{{- if eq .Values.externalMethod "WholeIP" }}
- port: 65535
{{- else }}
{{- range .Values.externalPorts }}
- name: port-{{ . }}
port: {{ . }}
targetPort: {{ . }}
{{- end }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions packages/apps/vm-instance/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"description": "Enable external access from outside the cluster",
"default": false
},
"externalMethod": {
"type": "string",
"description": "specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList`",
"default": "WholeIP",
"enum": [
"WholeIP",
"PortList"
]
},
"externalPorts": {
"type": "array",
"description": "Specify ports to forward from outside the cluster",
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/vm-instance/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## @section Common parameters

## @param external Enable external access from outside the cluster
## @param externalMethod specify method to passthrough the traffic to the virtual machine. Allowed values: `WholeIP` and `PortList`
## @param externalPorts [array] Specify ports to forward from outside the cluster
external: false
externalMethod: WholeIP
externalPorts:
- 22

Expand Down

0 comments on commit f768dc1

Please sign in to comment.