def create_object(config=None, name=None, obj_type=None): if config is None: config = create_config() obj = K8sObject( config=config, name=name, obj_type=obj_type ) return obj
def __init__(self, config=None, name=None): temp = K8sObject(config=config, obj_type='Pod', name='temp') _type = 'CronJob' if config and is_reachable(config.api_host): v = temp.server_version() if int(v['major']) == 1 and int(v['minor']) == 4: _type = 'ScheduledJob' super(K8sCronJob, self).__init__(config=config, obj_type=_type, name=name)
def __init__(self, config=None, name=None): if config and is_reachable(config.api_host): temp = K8sObject(config=config, obj_type='Pod', name='temp') v = temp.server_version() if int(v['major']) <= 1 and int(v['minor']) < 4: raise NotImplementedError( 'PetSets exist only on Kubernetes == 1.4.x.') if int(v['major']) >= 1 and int(v['minor']) >= 5: raise NotImplementedError( 'PetSets were refactored into StatefulSets on Kubernetes >= 1.5.x.' ) super(K8sPetSet, self).__init__(config=config, name=name, obj_type='PetSet')
def assert_server_version(api_host=None, major=None, minor=None, type='exact'): try: if not api_host: return False if is_reachable(api_host): cfg = K8sConfig(api_host=api_host) obj = K8sObject(config=cfg, obj_type='Pod', name='temp') v = obj.server_version() if type == 'exact': if int(v['major']) != major or int(v['minor']) != minor: msg = 'Desired: [ {}.{} ]. Observed: [ {}.{} ].'.format(major, minor, v['major'], v['minor']) raise VersionMismatchException(msg) return True return False except VersionMismatchException: return False
def __init__(self, config=None, name=None): temp = K8sObject(config=config, obj_type='Pod', name='temp') _type = 'CronJob' if config and is_reachable(config): v = temp.server_version() if int(v['major']) == 1 and int(v['minor']) == 4: _type = 'ScheduledJob' super(K8sCronJob, self).__init__( config=config, obj_type=_type, name=name ) if config is not None and config.pull_secret is not None: self.add_image_pull_secrets(config.pull_secret)
def server_version(): from kubernetes.K8sObject import K8sObject obj = K8sObject(obj_type='Pod', name='obj') v = obj.server_version() return v
def __init__(self, config=None, name=None): K8sObject.__init__(self, config=config, obj_type='Service', name=name) self.model = Service(name=name, namespace=self.config.namespace)
def __init__(self, name, obj_type, config=None): K8sObject.__init__(self, config=config, obj_type=obj_type, name=name)
def __init__(self, config=None, name=None): K8sObject.__init__(self, config=config, obj_type='Secret', name=name) self.model = Secret(name=name, namespace=self.config.get_namespace())