A kubernetes API wrapper class providing custom functionalities required by solo

Note: Take care if the same instance is used for parallel execution, as the behaviour may be unpredictable. For parallel execution, create separate instances by invoking clone()

Constructors

Properties

kubeClient: CoreV1Api
logger?: SoloLogger
PodReadyCondition: Map<string, string> = ...

Methods

  • Apply filters to metadata

    Parameters

    • items: any[]

      list of items

    • Optionalfilters: Record<string, string> = {}

      an object with metadata fields and value

    Returns any[]

    a list of items that match the filters

  • Copy a file from a container

    It overwrites any existing file at the destination directory

    Parameters

    • podName: `network-node${number}-0`
    • containerName: string
    • srcPath: string

      source file path in the container

    • destDir: string

      destination directory in the local

    Returns Promise<unknown>

  • Copy a file into a container

    It overwrites any existing file inside the container at the destination directory

    Parameters

    • podName: `network-node${number}-0`
    • containerName: string
    • srcPath: string

      source file path in the local

    • destDir: string

      destination directory in the container

    • Optionalfilter: TarCreateFilter = undefined

      the filter to pass to tar to keep or skip files or directories

    Returns Promise<boolean>

    a Promise that performs the copy operation

  • Create a new namespace

    Parameters

    • name: string

      name of the namespace

    Returns Promise<boolean>

  • Parameters

    • name: string

      for the config name

    • labels: Record<string, string>

      for the config metadata

    • data: Record<string, string>

      to contain in the config

    Returns Promise<boolean>

  • Parameters

    • namespace: string
    • leaseName: string
    • holderName: string
    • durationSeconds: number = 20

    Returns Promise<V1Lease>

  • creates a new Kubernetes secret with the provided attributes

    Parameters

    • name: string

      the name of the new secret

    • namespace: string

      the namespace to store the secret

    • secretType: string

      the secret type

    • data: Record<string, string>

      the secret, any values of a key:value pair must be base64 encoded

    • labels: Record<string, string>

      the label to use for future label selector queries

    • recreate: boolean

      if we should first run delete in the case that there the secret exists from a previous install

    Returns Promise<boolean>

    whether the secret was created successfully

  • Delete a namespace

    Parameters

    • name: string

      name of the namespace

    Returns Promise<boolean>

  • Parameters

    • name: string
    • namespace: string

    Returns Promise<boolean>

  • Parameters

    • name: string
    • namespace: string

    Returns Promise<V1Status>

  • Delete a persistent volume claim

    Parameters

    • name: string

      the name of the persistent volume claim to delete

    • namespace: string

      the namespace of the persistent volume claim to delete

    Returns Promise<boolean>

    true if the persistent volume claim was deleted

  • Delete a secret from the namespace

    Parameters

    • name: string

      the name of the existing secret

    • namespace: string

      the namespace to store the secret

    Returns Promise<boolean>

    whether the secret was deleted successfully

  • Invoke sh command within a container and return the console output as string

    Parameters

    • podName: string
    • containerName: string
    • command: string | string[]

      sh commands as an array to be run within the containerName (e.g 'ls -la /opt/hgcapp')

    Returns Promise<string>

    console output as string

  • Filter a single item using metadata filter

    Parameters

    • items: any[]

      list of items

    • Optionalfilters: Record<string, string> = {}

      an object with metadata fields and value

    Returns any

  • Get cluster IP of a service

    Parameters

    • svcName: string

      name of the service

    Returns Promise<string>

    cluster IP

  • Parameters

    • name: string

      name of the configmap

    Returns Promise<V1ConfigMap>

    the configmap if found

    SoloError - if the response if not found or the response is not OK

  • Download logs files from all network pods and save to local solo log directory

    Parameters

    • namespace: string

      the namespace of the network

    Returns Promise<any[]>

    a promise that resolves when the logs are downloaded

  • Parameters

    • pod: V1Pod
    • namespace: string

    Returns Promise<void>

  • Download state files from a pod

    Parameters

    • namespace: string

      the namespace of the network

    • nodeAlias: string

      the pod name

    Returns Promise<any[]>

    a promise that resolves when the state files are downloaded

  • Get a podName by name

    Parameters

    • name: string

      podName name

    Returns Promise<V1Pod>

  • Get host IP of a podName

    Parameters

    • podNameName: string

      name of the podName

    Returns Promise<string>

    podName IP

  • Get pods by labels

    Parameters

    • labels: string[] = []

      list of labels

    Returns Promise<V1Pod[]>

  • retrieve the secret of the given namespace and label selector, if there is more than one, it returns the first

    Parameters

    • namespace: string

      the namespace of the secret to search for

    • labelSelector: string

      the label selector used to fetch the Kubernetes secret

    Returns Promise<
        {
            data: Record<string, string>;
            labels: Record<string, string>;
            name: string;
            namespace: string;
            type: string;
        },
    >

    a custom secret object with the relevant attributes, the values of the data key:value pair objects must be base64 decoded

  • Get secrets by labels

    Parameters

    • labels: string[] = []

      list of labels

    Returns Promise<V1Secret[]>

  • Get a svc by name

    Parameters

    • name: string

      svc name

    Returns Promise<V1Service>

  • Check if a directory path exists in the container

    Parameters

    • podName: string
    • containerName: string
    • destPath: string

      path inside the container

    Returns Promise<boolean>

  • Check if a filepath exists in the container

    Parameters

    • podName: `network-node${number}-0`
    • containerName: string
    • destPath: string

      path inside the container

    • Optionalfilters: object = {}

      an object with metadata fields and value

    Returns Promise<boolean>

  • Returns true if a namespace exists with the given name

    Parameters

    • namespace: string

      namespace name

    Returns Promise<boolean>

  • Check if cert-manager is installed inside any namespace.

    Returns Promise<boolean>

    if cert-manager is found

  • Check if the ingress controller is installed inside any namespace.

    Returns Promise<boolean>

    if ingress controller is found

  • Check if minio is installed inside the namespace.

    Parameters

    • namespace: string

    Returns Promise<boolean>

    if minio is found

  • Parameters

    • namespace: string

    Returns Promise<boolean>

  • Get a pod by name and namespace, will check every 1 second until the pod is no longer found. Can throw a SoloError if there is an error while deleting the pod.

    Parameters

    • podName: string

      the name of the pod

    • namespace: string

      the namespace of the pod

    Returns Promise<void>

  • List files and directories in a container

    It runs ls -la on the specified path and returns a list of object containing the entries. For example: [{ directory: false, owner: hedera, group: hedera, size: 121, modifiedAt: Jan 15 13:50 name: config.txt }]

    Parameters

    • podName: `network-node${number}-0`
    • containerName: string
    • destPath: string

      path inside the container

    Returns Promise<TDirectoryData[]>

    a promise that returns array of directory entries, custom object

  • Get a list of persistent volume claim names for the given namespace

    Parameters

    • namespace: string

      the namespace of the persistent volume claims to return

    • Optionallabels: string[] = []

      labels

    Returns Promise<string[]>

    list of persistent volume claim names

  • Get a list of secrets for the given namespace

    Parameters

    • namespace: string

      the namespace of the secrets to return

    • Optionallabels: string[] = []

      labels

    Returns Promise<string[]>

    list of secret names

  • Parameters

    • podName: `network-node${number}-0`
    • containerName: string
    • destPath: string

    Returns Promise<string>

  • Port forward a port from a pod to localhost

    This simple server just forwards traffic from itself to a service running in kubernetes -> localhost:localPort -> port-forward-tunnel -> kubernetes-pod:targetPort

    Parameters

    • podName: `network-node${number}-0`
    • localPort: number
    • podPort: number

    Returns Promise<ExtendedNetServer>

  • Parameters

    • leaseName: string
    • namespace: string
    • timesCalled: number = 0

    Returns any

  • Parameters

    • localContext: LocalContextObject
    • messagePrefix: string
    • outputPassthroughStream: PassThrough
    • outputFileStream: WriteStream

    Returns void

  • Parameters

    • localContext: LocalContextObject
    • messagePrefix: string
    • outputPassthroughStream: PassThrough
    • outputFileStream: WriteStream

    Returns void

  • Parameters

    • leaseName: string
    • namespace: string
    • lease: V1Lease

    Returns Promise<V1Lease>

  • Parameters

    • name: string

      for the config name

    • labels: Record<string, string>

      for the config metadata

    • data: Record<string, string>

      to contain in the config

    Returns Promise<boolean>

  • Stop the port forwarder server

    Parameters

    • server: ExtendedNetServer

      an instance of server returned by portForward method

    • OptionalmaxAttempts: number = 20

      the maximum number of attempts to check if the server is stopped

    • Optionaltimeout: number = 500

      the delay between checks in milliseconds

    Returns Promise<void>

  • Parameters

    • context: string
    • cluster: string

    Returns Promise<boolean>

  • to test the connection to a pod within the network

    Parameters

    • host: string

      the host of the target connection

    • port: number

      the port of the target connection

    Returns Promise<boolean>

  • Parameters

    • lease: V1Lease
    • newHolderName: string

    Returns Promise<V1Lease>

  • Check pods for conditions

    Parameters

    • conditionsMap: Map<string, string>

      a map of conditions and values

    • Optionallabels: string[] = []

      pod labels

    • OptionalpodCount: number = 1

      number of pod expected

    • OptionalmaxAttempts: number = 10

      maximum attempts to check

    • Optionaldelay: number = 500

      delay between checks in milliseconds

    Returns Promise<V1Pod[]>

  • Check if pod is ready

    Parameters

    • Optionallabels: string[] = []

      pod labels

    • OptionalpodCount: number = 1

      number of pod expected

    • OptionalmaxAttempts: number = 10

      maximum attempts to check

    • Optionaldelay: number = 500

      delay between checks in milliseconds

    Returns Promise<V1Pod[]>

  • Parameters

    • phases: string[] = ...
    • labels: string[] = []
    • podCount: number = 1
    • maxAttempts: number = constants.PODS_RUNNING_MAX_ATTEMPTS
    • delay: number = constants.PODS_RUNNING_DELAY
    • OptionalpodItemPredicate: (items: V1Pod) => boolean

    Returns Promise<V1Pod[]>