Example #1
0
    def __init__(self, model=None):
        super(PodSpec, self).__init__()

        self._active_deadline_seconds = None
        self._affinity = None
        self._containers = []
        self._automount_service_account_token = True
        self._dns_policy = 'Default'
        self._host_ipc = None
        self._host_network = None
        self._host_pid = None
        self._hostname = None
        self._image_pull_secrets = None
        self._node_name = None
        self._node_selector = {}
        self._restart_policy = 'Always'
        self._security_context = PodSecurityContext()
        self._service_account = None  # deprecated
        self._service_account_name = None
        self._subdomain = None
        self._termination_grace_period_seconds = 30
        self._tolerations = []
        self._volumes = []

        if model is not None:
            m = filter_model(model)
            self._build_with_model(m)
Example #2
0
 def _build_with_model(self, model=None):
     if 'activeDeadlineSeconds' in model:
         self.active_deadline_seconds = model['activeDeadlineSeconds']
     if 'affinity' in model:
         self.affinity = Affinity(model['affinity'])
     if 'containers' in model:
         containers = []
         for c in model['containers']:
             container = Container(c)
             containers.append(container)
         self.containers = containers
     if 'dnsPolicy' in model:
         self.dns_policy = model['dnsPolicy']
     if 'hostIPC' in model:
         self.host_ipc = model['hostIPC']
     if 'hostNetwork' in model:
         self.host_network = model['hostNetwork']
     if 'hostPID' in model:
         self.host_pid = model['hostPID']
     if 'hostname' in model:
         self.hostname = model['hostname']
     if 'imagePullSecrets' in model:
         self.image_pull_secrets = model['imagePullSecrets']
     if 'nodeName' in model:
         self.node_name = model['nodeName']
     if 'nodeSelector' in model:
         self.node_selector = model['nodeSelector']
     if 'restartPolicy' in model:
         self.restart_policy = model['restartPolicy']
     if 'securityContext' in model:
         self.security_context = PodSecurityContext(
             model['securityContext'])
     if 'serviceAccount' in model:
         self.service_account = model['serviceAccount']
     if 'serviceAccountName' in model:
         self.service_account_name = model['serviceAccountName']
     if 'subdomain' in model:
         self.subdomain = model['subdomain']
     if 'terminationGracePeriodSeconds' in model:
         self.termination_grace_period_seconds = model[
             'terminationGracePeriodSeconds']
     if 'tolerations' in model:
         tolerations = []
         for t in model['tolerations']:
             tol = Toleration(t)
             tolerations.append(tol)
         self.tolerations = tolerations
     if 'volumes' in model:
         volumes = []
         for v in model['volumes']:
             volume = Volume(v)
             volumes.append(volume)
         self.volumes = volumes