Skip to content

Commit

Permalink
Merge pull request #230 from flux-framework/add-additional-pod-attrib…
Browse files Browse the repository at this point in the history
…utes

pod: additional features for skypilot
  • Loading branch information
vsoch authored Jul 21, 2024
2 parents 6a22353 + 33af57d commit 678b187
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 18 deletions.
8 changes: 8 additions & 0 deletions api/v1alpha2/minicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,18 @@ type PodSpec struct {
// +optional
Labels map[string]string `json:"labels"`

// Restart Policy
// +optional
RestartPolicy string `json:"restartPolicy,omitempty"`

// Service account name for the pod
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// Automatically mount the service account name
// +optional
AutomountServiceAccountToken bool `json:"automountServiceAccountToken,omitempty"`

// Scheduler name for the pod
// +optional
SchedulerName string `json:"schedulerName,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions api/v1alpha2/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@
"default": ""
}
},
"automountServiceAccountToken": {
"description": "Automatically mount the service account name",
"type": "boolean"
},
"labels": {
"description": "Labels for each pod",
"type": "object",
Expand All @@ -767,6 +771,10 @@
"$ref": "#/definitions/IntOrString"
}
},
"restartPolicy": {
"description": "Restart Policy",
"type": "string"
},
"schedulerName": {
"description": "Scheduler name for the pod",
"type": "string"
Expand Down
14 changes: 14 additions & 0 deletions api/v1alpha2/zz_generated.openapi.go

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

6 changes: 6 additions & 0 deletions chart/templates/minicluster-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ spec:
type: string
description: Annotations for each pod
type: object
automountServiceAccountToken:
description: Automatically mount the service account name
type: boolean
labels:
additionalProperties:
type: string
Expand All @@ -549,6 +552,9 @@ spec:
x-kubernetes-int-or-string: true
description: Resources include limits and requests
type: object
restartPolicy:
description: Restart Policy
type: string
schedulerName:
description: Scheduler name for the pod
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/flux-framework.org_miniclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ spec:
type: string
description: Annotations for each pod
type: object
automountServiceAccountToken:
description: Automatically mount the service account name
type: boolean
labels:
additionalProperties:
type: string
Expand All @@ -552,6 +555,9 @@ spec:
x-kubernetes-int-or-string: true
description: Resources include limits and requests
type: object
restartPolicy:
description: Restart Policy
type: string
schedulerName:
description: Scheduler name for the pod
type: string
Expand Down
19 changes: 10 additions & 9 deletions controllers/flux/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ func NewMiniClusterJob(cluster *api.MiniCluster) (*batchv1.Job, error) {
},
Spec: corev1.PodSpec{
// matches the service
Subdomain: cluster.Spec.Network.HeadlessName,
ShareProcessNamespace: &cluster.Spec.ShareProcessNamespace,
SetHostnameAsFQDN: &setAsFQDN,
Volumes: getVolumes(cluster),
RestartPolicy: corev1.RestartPolicyOnFailure,
ImagePullSecrets: getImagePullSecrets(cluster),
ServiceAccountName: cluster.Spec.Pod.ServiceAccountName,
NodeSelector: cluster.Spec.Pod.NodeSelector,
SchedulerName: cluster.Spec.Pod.SchedulerName,
Subdomain: cluster.Spec.Network.HeadlessName,
ShareProcessNamespace: &cluster.Spec.ShareProcessNamespace,
SetHostnameAsFQDN: &setAsFQDN,
Volumes: getVolumes(cluster),
ImagePullSecrets: getImagePullSecrets(cluster),
ServiceAccountName: cluster.Spec.Pod.ServiceAccountName,
AutomountServiceAccountToken: &cluster.Spec.Pod.AutomountServiceAccountToken,
RestartPolicy: corev1.RestartPolicy(cluster.Spec.Pod.RestartPolicy),
NodeSelector: cluster.Spec.Pod.NodeSelector,
SchedulerName: cluster.Spec.Pod.SchedulerName,
},
},
},
Expand Down
17 changes: 9 additions & 8 deletions controllers/flux/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ func (r *MiniClusterReconciler) newServicePod(
},
Spec: corev1.PodSpec{
// This is the headless service name
Subdomain: cluster.Spec.Network.HeadlessName,
Hostname: podServiceName,
SetHostnameAsFQDN: &setAsFQDN,
Volumes: existingVolumes,
RestartPolicy: corev1.RestartPolicyOnFailure,
ImagePullSecrets: getImagePullSecrets(cluster),
ServiceAccountName: cluster.Spec.Pod.ServiceAccountName,
NodeSelector: cluster.Spec.Pod.NodeSelector,
Subdomain: cluster.Spec.Network.HeadlessName,
Hostname: podServiceName,
SetHostnameAsFQDN: &setAsFQDN,
Volumes: existingVolumes,
ImagePullSecrets: getImagePullSecrets(cluster),
RestartPolicy: corev1.RestartPolicy(cluster.Spec.Pod.RestartPolicy),
ServiceAccountName: cluster.Spec.Pod.ServiceAccountName,
AutomountServiceAccountToken: &cluster.Spec.Pod.AutomountServiceAccountToken,
NodeSelector: cluster.Spec.Pod.NodeSelector,
},
}

Expand Down
6 changes: 6 additions & 0 deletions examples/dist/flux-operator-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ spec:
type: string
description: Annotations for each pod
type: object
automountServiceAccountToken:
description: Automatically mount the service account name
type: boolean
labels:
additionalProperties:
type: string
Expand All @@ -558,6 +561,9 @@ spec:
x-kubernetes-int-or-string: true
description: Resources include limits and requests
type: object
restartPolicy:
description: Restart Policy
type: string
schedulerName:
description: Scheduler name for the pod
type: string
Expand Down
6 changes: 6 additions & 0 deletions examples/dist/flux-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ spec:
type: string
description: Annotations for each pod
type: object
automountServiceAccountToken:
description: Automatically mount the service account name
type: boolean
labels:
additionalProperties:
type: string
Expand All @@ -558,6 +561,9 @@ spec:
x-kubernetes-int-or-string: true
description: Resources include limits and requests
type: object
restartPolicy:
description: Restart Policy
type: string
schedulerName:
description: Scheduler name for the pod
type: string
Expand Down
1 change: 1 addition & 0 deletions examples/interactive/minicluster-persistent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ spec:
# source /mnt/flux/flux-view.sh
# flux proxy $fluxsocket bash
# flux resource list
# flux getattr broker.rc1_path

# This starts the flux broker without a command (interactive)
interactive: true
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/v1alpha2/docs/PodSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ PodSpec controlls variables for the cluster pod
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**annotations** | **dict[str, str]** | Annotations for each pod | [optional]
**automount_service_account_token** | **bool** | Automatically mount the service account name | [optional]
**labels** | **dict[str, str]** | Labels for each pod | [optional]
**node_selector** | **dict[str, str]** | NodeSelectors for a pod | [optional]
**resources** | [**dict[str, IntOrString]**](IntOrString.md) | Resources include limits and requests | [optional]
**restart_policy** | **str** | Restart Policy | [optional]
**scheduler_name** | **str** | Scheduler name for the pod | [optional]
**service_account_name** | **str** | Service account name for the pod | [optional]

Expand Down
58 changes: 57 additions & 1 deletion sdk/python/v1alpha2/fluxoperator/models/pod_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,54 @@ class PodSpec(object):
"""
openapi_types = {
'annotations': 'dict[str, str]',
'automount_service_account_token': 'bool',
'labels': 'dict[str, str]',
'node_selector': 'dict[str, str]',
'resources': 'dict[str, IntOrString]',
'restart_policy': 'str',
'scheduler_name': 'str',
'service_account_name': 'str'
}

attribute_map = {
'annotations': 'annotations',
'automount_service_account_token': 'automountServiceAccountToken',
'labels': 'labels',
'node_selector': 'nodeSelector',
'resources': 'resources',
'restart_policy': 'restartPolicy',
'scheduler_name': 'schedulerName',
'service_account_name': 'serviceAccountName'
}

def __init__(self, annotations=None, labels=None, node_selector=None, resources=None, scheduler_name=None, service_account_name=None, local_vars_configuration=None): # noqa: E501
def __init__(self, annotations=None, automount_service_account_token=None, labels=None, node_selector=None, resources=None, restart_policy=None, scheduler_name=None, service_account_name=None, local_vars_configuration=None): # noqa: E501
"""PodSpec - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration.get_default_copy()
self.local_vars_configuration = local_vars_configuration

self._annotations = None
self._automount_service_account_token = None
self._labels = None
self._node_selector = None
self._resources = None
self._restart_policy = None
self._scheduler_name = None
self._service_account_name = None
self.discriminator = None

if annotations is not None:
self.annotations = annotations
if automount_service_account_token is not None:
self.automount_service_account_token = automount_service_account_token
if labels is not None:
self.labels = labels
if node_selector is not None:
self.node_selector = node_selector
if resources is not None:
self.resources = resources
if restart_policy is not None:
self.restart_policy = restart_policy
if scheduler_name is not None:
self.scheduler_name = scheduler_name
if service_account_name is not None:
Expand Down Expand Up @@ -103,6 +113,29 @@ def annotations(self, annotations):

self._annotations = annotations

@property
def automount_service_account_token(self):
"""Gets the automount_service_account_token of this PodSpec. # noqa: E501
Automatically mount the service account name # noqa: E501
:return: The automount_service_account_token of this PodSpec. # noqa: E501
:rtype: bool
"""
return self._automount_service_account_token

@automount_service_account_token.setter
def automount_service_account_token(self, automount_service_account_token):
"""Sets the automount_service_account_token of this PodSpec.
Automatically mount the service account name # noqa: E501
:param automount_service_account_token: The automount_service_account_token of this PodSpec. # noqa: E501
:type automount_service_account_token: bool
"""

self._automount_service_account_token = automount_service_account_token

@property
def labels(self):
"""Gets the labels of this PodSpec. # noqa: E501
Expand Down Expand Up @@ -172,6 +205,29 @@ def resources(self, resources):

self._resources = resources

@property
def restart_policy(self):
"""Gets the restart_policy of this PodSpec. # noqa: E501
Restart Policy # noqa: E501
:return: The restart_policy of this PodSpec. # noqa: E501
:rtype: str
"""
return self._restart_policy

@restart_policy.setter
def restart_policy(self, restart_policy):
"""Sets the restart_policy of this PodSpec.
Restart Policy # noqa: E501
:param restart_policy: The restart_policy of this PodSpec. # noqa: E501
:type restart_policy: str
"""

self._restart_policy = restart_policy

@property
def scheduler_name(self):
"""Gets the scheduler_name of this PodSpec. # noqa: E501
Expand Down

0 comments on commit 678b187

Please sign in to comment.