Skip to content

Commit

Permalink
feature: add hostNetwork to the podSpec (envoyproxy#1944)
Browse files Browse the repository at this point in the history
* added hostNetwork to the podSpec

Signed-off-by: tanujd11 <dwiveditanuj41@gmail.com>

* make gen-check

Signed-off-by: tanujd11 <dwiveditanuj41@gmail.com>

---------

Signed-off-by: tanujd11 <dwiveditanuj41@gmail.com>
Co-authored-by: Xunzhuo <bitliu@tencent.com>
  • Loading branch information
tanujd11 and Xunzhuo authored Dec 14, 2023
1 parent 176823c commit 9aebfdc
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ type KubernetesPodSpec struct {
//
// +optional
Volumes []corev1.Volume `json:"volumes,omitempty"`

// HostNetwork, If this is set to true, the pod will use host's network namespace.
// +optional
HostNetwork bool `json:"hostNetwork,omitempty"`
}

// KubernetesContainerSpec defines the desired state of the Kubernetes container resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3024,6 +3024,10 @@ spec:
should be appended to the pods. By default, no pod
annotations are appended.
type: object
hostNetwork:
description: HostNetwork, If this is set to true,
the pod will use host's network namespace.
type: boolean
labels:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
RestartPolicy: corev1.RestartPolicyAlways,
SchedulerName: "default-scheduler",
SecurityContext: deploymentConfig.Pod.SecurityContext,
HostNetwork: deploymentConfig.Pod.HostNetwork,
Affinity: deploymentConfig.Pod.Affinity,
Tolerations: deploymentConfig.Pod.Tolerations,
Volumes: expectedDeploymentVolumes(r.infra.Name, deploymentConfig),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func TestDeployment(t *testing.T) {
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
},
HostNetwork: true,
},
Container: &egv1a1.KubernetesContainerSpec{
Image: pointer.String("envoyproxy/envoy:v1.2.3"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ spec:
prometheus.io/scrape: "true"
spec:
automountServiceAccountToken: false
hostNetwork: true
containers:
- args:
- --service-cluster default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
RestartPolicy: corev1.RestartPolicyAlways,
SchedulerName: "default-scheduler",
SecurityContext: r.rateLimitDeployment.Pod.SecurityContext,
HostNetwork: r.rateLimitDeployment.Pod.HostNetwork,
Volumes: expectedDeploymentVolumes(r.rateLimit, r.rateLimitDeployment),
Affinity: r.rateLimitDeployment.Pod.Affinity,
Tolerations: r.rateLimitDeployment.Pod.Tolerations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func TestDeployment(t *testing.T) {
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: pointer.Int64(1000),
},
HostNetwork: true,
},
Container: &egv1a1.KubernetesContainerSpec{
Image: pointer.String("custom-image"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
prometheus.io/scrape: "true"
spec:
automountServiceAccountToken: false
hostNetwork: true
containers:
- command:
- /bin/ratelimit
Expand Down
1 change: 1 addition & 0 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ _Appears in:_
| `affinity` _[Affinity](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#affinity-v1-core)_ | If specified, the pod's scheduling constraints. |
| `tolerations` _[Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#toleration-v1-core) array_ | If specified, the pod's tolerations. |
| `volumes` _[Volume](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#volume-v1-core) array_ | Volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes |
| `hostNetwork` _boolean_ | HostNetwork, If this is set to true, the pod will use host's network namespace. |


#### KubernetesServiceSpec
Expand Down

0 comments on commit 9aebfdc

Please sign in to comment.