Skip to content

Commit

Permalink
Merge pull request #67 from mfranczy/add-huge-page-support
Browse files Browse the repository at this point in the history
Add hugepages support
  • Loading branch information
mfranczy authored Oct 1, 2020
2 parents fa6cd76 + 167b29e commit 7825ccf
Show file tree
Hide file tree
Showing 46 changed files with 27,442 additions and 14 deletions.
4 changes: 4 additions & 0 deletions charts/internal/machine-class/templates/machine-class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ providerSpec:
dnsConfig:
{{ toYaml $machineClass.dnsConfig | indent 4 }}
{{- end }}
{{- if $machineClass.memoryFeatures }}
memoryFeatures:
{{ toYaml $machineClass.memoryFeatures | indent 4 }}
{{- end }}
secretRef:
name: "{{ $machineClass.name }}"
namespace: "{{ $.Release.Namespace }}"
Expand Down
3 changes: 3 additions & 0 deletions charts/internal/machine-class/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ machineClasses:
dnsConfig:
nameservers:
- 8.8.8.8
memoryFeatures:
hugepages:
pageSize: "2Mi"
secret:
cloudConfig: abc
kubeconfig: abc
7 changes: 7 additions & 0 deletions docs/usage-as-end-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ dnsConfig:
- 8.8.8.8
# Disable using pre-allocated data volumes. Defaults to 'false'.
disablePreAllocatedDataVolumes: true
# Memory features configuration for KubeVirt VMs, allows to set 'hugepages' settings.
# It requires appropriate feature gate to be enabled, take a look at the following links for more details:
# * k8s - https://kubernetes.io/docs/tasks/manage-hugepages/scheduling-hugepages/
# * okd - https://docs.okd.io/latest/scalability_and_performance/what-huge-pages-do-and-how-they-are-consumed-by-apps.html
memoryFeatures:
hugepages:
pageSize: "2Mi"
```
Currently, these KubeVirt-specific options may include:
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ require (
k8s.io/apimachinery v0.18.3
k8s.io/apiserver v0.17.9
k8s.io/autoscaler v0.0.0-20190805135949-100e91ba756e
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/client-go v12.0.0+incompatible
k8s.io/code-generator v0.18.3
k8s.io/component-base v0.17.9
k8s.io/kubelet v0.17.9
k8s.io/utils v0.0.0-20200327001022-6496210b90e8
kubevirt.io/client-go v0.33.0
kubevirt.io/containerized-data-importer v1.10.6
sigs.k8s.io/controller-runtime v0.5.5
)
Expand Down
54 changes: 54 additions & 0 deletions go.sum

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions hack/api-reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,21 @@ string
</tr>
<tr>
<td>
<code>memoryFeatures</code></br>
<em>
kubevirt.io/client-go/api/v1.Memory
</em>
</td>
<td>
<p>MemoryFeatures allows specifying the VirtualMachineInstance memory features like huge pages and guest memory settings.
Each feature might require appropriate FeatureGate enabled.
For hugepages take a look at:
k8s - <a href="https://kubernetes.io/docs/tasks/manage-hugepages/scheduling-hugepages/">https://kubernetes.io/docs/tasks/manage-hugepages/scheduling-hugepages/</a>
okd - <a href="https://docs.okd.io/3.9/scaling_performance/managing_hugepages.html#huge-pages-prerequisites">https://docs.okd.io/3.9/scaling_performance/managing_hugepages.html#huge-pages-prerequisites</a></p>
</td>
</tr>
<tr>
<td>
<code>dnsPolicy</code></br>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#dnspolicy-v1-core">
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/kubevirt/types_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package kubevirt
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubevirtv1 "kubevirt.io/client-go/api/v1"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -25,6 +26,12 @@ import (
type WorkerConfig struct {
metav1.TypeMeta

// MemoryFeatures allows specifying the VirtualMachineInstance memory features like huge pages and guest memory settings.
// Each feature might require appropriate FeatureGate enabled.
// For hugepages take a look at:
// k8s - https://kubernetes.io/docs/tasks/manage-hugepages/scheduling-hugepages/
// okd - https://docs.okd.io/3.9/scaling_performance/managing_hugepages.html#huge-pages-prerequisites
MemoryFeatures *kubevirtv1.Memory
// Set DNS policy for the VM (the same options as for the pod)
// Defaults to "ClusterFirst".
// Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'.
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/kubevirt/v1alpha1/types_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubevirtv1 "kubevirt.io/client-go/api/v1"
)

// +genclient
Expand All @@ -26,6 +27,12 @@ import (
type WorkerConfig struct {
metav1.TypeMeta `json:",inline"`

// MemoryFeatures allows specifying the VirtualMachineInstance memory features like huge pages and guest memory settings.
// Each feature might require appropriate FeatureGate enabled.
// For hugepages take a look at:
// k8s - https://kubernetes.io/docs/tasks/manage-hugepages/scheduling-hugepages/
// okd - https://docs.okd.io/3.9/scaling_performance/managing_hugepages.html#huge-pages-prerequisites
MemoryFeatures *kubevirtv1.Memory `json:"memoryFeatures,omitempty"`
// Set DNS policy for the VM (the same as for the pod)
// Defaults to "ClusterFirst".
// Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'.
Expand Down
13 changes: 8 additions & 5 deletions pkg/apis/kubevirt/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions pkg/apis/kubevirt/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions pkg/apis/kubevirt/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error {
"dnsPolicy": workerConfig.DNSPolicy,
"dnsConfig": workerConfig.DNSConfig,
"disablePreAllocatedDataVolumes": workerConfig.DisablePreAllocatedDataVolumes,
"memoryFeatures": workerConfig.MemoryFeatures,
})

machineDeployments = append(machineDeployments, worker.MachineDeployment{
Expand Down
16 changes: 15 additions & 1 deletion pkg/controller/worker/machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
kubevirtv1 "kubevirt.io/client-go/api/v1"
cdicorev1alpha1 "kubevirt.io/containerized-data-importer/pkg/apis/core/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -181,6 +182,11 @@ var _ = Describe("Machines", func() {
Nameservers: []string{dnsNameserver},
},
DisablePreAllocatedDataVolumes: true,
MemoryFeatures: &kubevirtv1.Memory{
Hugepages: &kubevirtv1.Hugepages{
PageSize: "2Mi",
},
},
}),
},
},
Expand Down Expand Up @@ -271,6 +277,11 @@ var _ = Describe("Machines", func() {
Nameservers: []string{dnsNameserver},
},
true,
&kubevirtv1.Memory{
Hugepages: &kubevirtv1.Hugepages{
PageSize: "2Mi",
},
},
)

machineClass2 := generateMachineClass(
Expand All @@ -288,6 +299,7 @@ var _ = Describe("Machines", func() {
"",
nil,
false,
nil,
)

chartApplier.
Expand Down Expand Up @@ -485,7 +497,8 @@ func generateKubeVirtDataVolumes(providerClient *mockclient.MockClient) {
}

func generateMachineClass(classTemplate map[string]interface{}, name, pvcSize, cpu, memory string, zones []string,
tags map[string]string, dnsPolicy corev1.DNSPolicy, dnsConfig *corev1.PodDNSConfig, disablePreAllocatedDataVolumes bool) map[string]interface{} {
tags map[string]string, dnsPolicy corev1.DNSPolicy, dnsConfig *corev1.PodDNSConfig, disablePreAllocatedDataVolumes bool,
memoryFeatures *kubevirtv1.Memory) map[string]interface{} {
out := make(map[string]interface{})

for k, v := range classTemplate {
Expand All @@ -501,6 +514,7 @@ func generateMachineClass(classTemplate map[string]interface{}, name, pvcSize, c
out["dnsPolicy"] = dnsPolicy
out["dnsConfig"] = dnsConfig
out["disablePreAllocatedDataVolumes"] = disablePreAllocatedDataVolumes
out["memoryFeatures"] = memoryFeatures

return out
}
Expand Down
10 changes: 10 additions & 0 deletions vendor/github.com/pborman/uuid/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/pborman/uuid/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/pborman/uuid/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/pborman/uuid/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/pborman/uuid/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7825ccf

Please sign in to comment.