Skip to content

Commit 967c3c8

Browse files
vsochaojea
andauthored
Remove host network (#205)
* allow to use hostNetwork pods * regenerate code and manifests * move hostNetwork under spec->network * test adding weight of 100 (assuming each of pod affinity and anti affinity add to 100 Also add documentation to custom-resource-definition.md and move pode affinity generation into own function. Update associated python sdk and add test. I am too afraid to run this with hostNetwork on my local machine. Co-authored-by: Antonio Ojea <[email protected]>
1 parent 155effc commit 967c3c8

File tree

5 files changed

+63
-72
lines changed

5 files changed

+63
-72
lines changed

controllers/flux/job.go

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -71,46 +71,7 @@ func NewMiniClusterJob(cluster *api.MiniCluster) (*batchv1.Job, error) {
7171
ImagePullSecrets: getImagePullSecrets(cluster),
7272
ServiceAccountName: cluster.Spec.Pod.ServiceAccountName,
7373
NodeSelector: cluster.Spec.Pod.NodeSelector,
74-
Affinity: &corev1.Affinity{
75-
// Prefer to schedule pods on the same zone
76-
PodAffinity: &corev1.PodAffinity{
77-
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
78-
{
79-
PodAffinityTerm: corev1.PodAffinityTerm{
80-
LabelSelector: &metav1.LabelSelector{
81-
MatchExpressions: []metav1.LabelSelectorRequirement{
82-
{
83-
Key: podLabelAppName, // added in getPodLabels
84-
Operator: metav1.LabelSelectorOpIn,
85-
Values: []string{cluster.Name},
86-
},
87-
},
88-
},
89-
TopologyKey: "topology.kubernetes.io/zone",
90-
},
91-
},
92-
},
93-
},
94-
// Prefer to schedule pods on different nodes
95-
PodAntiAffinity: &corev1.PodAntiAffinity{
96-
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
97-
{
98-
PodAffinityTerm: corev1.PodAffinityTerm{
99-
LabelSelector: &metav1.LabelSelector{
100-
MatchExpressions: []metav1.LabelSelectorRequirement{
101-
{
102-
Key: podLabelAppName, // added in getPodLabels
103-
Operator: metav1.LabelSelectorOpIn,
104-
Values: []string{cluster.Name},
105-
},
106-
},
107-
},
108-
TopologyKey: "kubernetes.io/hostname",
109-
},
110-
},
111-
},
112-
},
113-
},
74+
Affinity: getAffinity(cluster),
11475
},
11576
},
11677
},
@@ -137,6 +98,54 @@ func NewMiniClusterJob(cluster *api.MiniCluster) (*batchv1.Job, error) {
13798
return job, err
13899
}
139100

101+
// getAffinity returns to pod affinity to ensure 1 address / node
102+
func getAffinity(cluster *api.MiniCluster) *corev1.Affinity {
103+
return &corev1.Affinity{
104+
// Prefer to schedule pods on the same zone
105+
PodAffinity: &corev1.PodAffinity{
106+
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
107+
{
108+
Weight: 100,
109+
PodAffinityTerm: corev1.PodAffinityTerm{
110+
LabelSelector: &metav1.LabelSelector{
111+
MatchExpressions: []metav1.LabelSelectorRequirement{
112+
{
113+
// added in getPodLabels
114+
Key: podLabelAppName,
115+
Operator: metav1.LabelSelectorOpIn,
116+
Values: []string{cluster.Name},
117+
},
118+
},
119+
},
120+
TopologyKey: "topology.kubernetes.io/zone",
121+
},
122+
},
123+
},
124+
},
125+
// Prefer to schedule pods on different nodes
126+
PodAntiAffinity: &corev1.PodAntiAffinity{
127+
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
128+
{
129+
Weight: 100,
130+
PodAffinityTerm: corev1.PodAffinityTerm{
131+
LabelSelector: &metav1.LabelSelector{
132+
MatchExpressions: []metav1.LabelSelectorRequirement{
133+
{
134+
// added in getPodLabels
135+
Key: podLabelAppName,
136+
Operator: metav1.LabelSelectorOpIn,
137+
Values: []string{cluster.Name},
138+
},
139+
},
140+
},
141+
TopologyKey: "kubernetes.io/hostname",
142+
},
143+
},
144+
},
145+
},
146+
}
147+
}
148+
140149
// getImagePullSecrets returns a list of secret object references for each container.
141150
func getImagePullSecrets(cluster *api.MiniCluster) []corev1.LocalObjectReference {
142151
pullSecrets := []corev1.LocalObjectReference{}

docs/getting_started/custom-resource-definition.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,19 @@ If you want to disable this cleanup:
287287
If you are streaming the logs with `kubectl logs` the steam would stop when the broker pod is completed,
288288
so typically you will get the logs as long as you are streaming when the job starts running.
289289

290+
### network
291+
292+
The network section exposes networking options for the Flux MiniCluster.
293+
294+
#### headlessName
295+
296+
Change the default headless service name (defaults to `flux-service`).
297+
298+
```yaml
299+
network:
300+
headlessName: my-network
301+
```
302+
290303
### flux
291304

292305
Settings under the Flux directive typically refer to flux options, e.g., for the broker or similar.

examples/tests/hello-world/00-hello-world.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/tests/hello-world/test.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

sdk/python/v1alpha1/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
1414
The versions coincide with releases on pip. Only major versions will be released as tags on Github.
1515

1616
## [0.0.x](https://github.com/flux-framework/flux-operator/tree/main/sdk/python/v2alpha1) (0.0.x)
17+
- support for pod affinity/anti-affinity (0.1.1)
1718
- first release alongside flux operator (0.1.0)
1819
- support for bursting and curve cert as a secret (0.0.31)
1920
- support for simple bursting (0.0.3)

0 commit comments

Comments
 (0)