class Kubes::Compiler::Dsl::Syntax::Deployment

Public Instance Methods

command_reader() click to toggle source

Override command instead of default_command since we want to change a String to an Array

# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 239
def command_reader
  @command.is_a?(String) ? @command.split(' ') : @command # else assume Array
end
default_apiVersion() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 92
def default_apiVersion
  "apps/v1"
end
default_container() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 201
def default_container
  {
    args: args,
    command: command,
    env: env,
    envFrom: envFrom,
    image: image,
    imagePullPolicy: imagePullPolicy,
    lifecycle: lifecycle,
    livenessProbe: livenessProbe,
    name: containerName || name,
    ports: ports,
    readinessProbe: readinessProbe,
    resources: resources,
    securityContext: securityContext,
    startupProbe: startupProbe,
    stdin: stdin,
    stdinOnce: stdinOnce,
    terminationMessagePath: terminationMessagePath,
    terminationMessagePolicy: terminationMessagePolicy,
    tty: tty,
    volumeDevices: volumeDevices,
    volumeMounts: volumeMounts,
    workingDir: workingDir,
  }
end
default_containers() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 186
def default_containers
  [container, sidecar].compact
end
default_matchLabels() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 117
def default_matchLabels
  labels
end
default_ports() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 228
def default_ports
  [
    containerPort: containerPort,
    hostIP: hostIP,
    hostPort: hostPort,
    name: portName,
    protocol: protocol,
  ]
end
default_replicas() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 109
def default_replicas
  1
end
default_selector() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 113
def default_selector
  { matchLabels: matchLabels }
end
default_sidecar() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 190
def default_sidecar
  {
    name:  sidecar_name,
    image: sidecar_image,
  }
end
default_sidecar_name() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 197
def default_sidecar_name
  "sidecar" if sidecar_image # othewise will create invalid sidecar field w/o image
end
default_spec() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 96
def default_spec
  {
    minReadySeconds: minReadySeconds,
    paused: paused,
    progressDeadlineSeconds: progressDeadlineSeconds,
    replicas: replicas,
    revisionHistoryLimit: revisionHistoryLimit,
    selector: selector,
    strategy: strategy,
    template: template,
  }
end
default_strategy() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 121
def default_strategy
  return unless maxUnavailable || maxSurge

  maxSurge = maxUnavailable if maxUnavailable && !maxSurge
  maxUnavailable = maxSurge if !maxUnavailable && maxSurge

  {
    rollingUpdate: {
      maxSurge: maxSurge,
      maxUnavailable: maxUnavailable,
    },
    type: "RollingUpdate",
  }
end
default_template() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 136
def default_template
  {
    metadata: templateMetadata,
    spec: templateSpec,
  }
end
default_templateMetadata() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 182
def default_templateMetadata
  { labels: labels }
end
default_templateSpec() click to toggle source
# File lib/kubes/compiler/dsl/syntax/deployment.rb, line 143
def default_templateSpec
  {
    activeDeadlineSeconds: activeDeadlineSeconds,
    affinity: affinity,
    automountServiceAccountToken: automountServiceAccountToken,
    containers: containers,
    dnsConfig: dnsConfig,
    dnsPolicy: dnsPolicy,
    enableServiceLinks: enableServiceLinks,
    ephemeralContainers: ephemeralContainers,
    hostAliases: hostAliases,
    hostIPC: hostIPC,
    hostNetwork: hostNetwork,
    hostPID: hostPID,
    hostname: hostname,
    imagePullSecrets: imagePullSecrets,
    initContainers: initContainers,
    nodeName: nodeName,
    nodeSelector: nodeSelector,
    overhead: overhead,
    preemptionPolicy: preemptionPolicy,
    priority: priority,
    priorityClassName: priorityClassName,
    readinessGates: readinessGates,
    restartPolicy: restartPolicy,
    runtimeClassName: runtimeClassName,
    schedulerName: schedulerName,
    securityContext: securityContext,
    serviceAccount: serviceAccount,
    serviceAccountName: serviceAccountName,
    shareProcessNamespace: shareProcessNamespace,
    subdomain: subdomain,
    terminationGracePeriodSeconds: terminationGracePeriodSeconds,
    tolerations: tolerations,
    topologySpreadConstraints: topologySpreadConstraints,
    volumes: volumes,
  }
end