Class: Kubes::Compiler::Dsl::Syntax::Deployment

Inherits:
Resource
  • Object
show all
Defined in:
lib/kubes/compiler/dsl/syntax/deployment.rb

Instance Attribute Summary

Attributes inherited from Resource

#kind_from_block

Instance Method Summary collapse

Methods inherited from Resource

#default_kind, #default_metadata, #default_result, #default_result_append, #default_top, #field, #top

Methods included from Util::Normalize

#extract_type, #normalize_kind

Instance Method Details

#command_readerObject

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



239
240
241
# 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_apiVersionObject



92
93
94
# File 'lib/kubes/compiler/dsl/syntax/deployment.rb', line 92

def default_apiVersion
  "apps/v1"
end

#default_containerObject



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# 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_containersObject



186
187
188
# File 'lib/kubes/compiler/dsl/syntax/deployment.rb', line 186

def default_containers
  [container, sidecar].compact
end

#default_matchLabelsObject



117
118
119
# File 'lib/kubes/compiler/dsl/syntax/deployment.rb', line 117

def default_matchLabels
  labels
end

#default_portsObject



228
229
230
231
232
233
234
235
236
# 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_replicasObject



109
110
111
# File 'lib/kubes/compiler/dsl/syntax/deployment.rb', line 109

def default_replicas
  1
end

#default_selectorObject



113
114
115
# File 'lib/kubes/compiler/dsl/syntax/deployment.rb', line 113

def default_selector
  { matchLabels: matchLabels }
end

#default_sidecarObject



190
191
192
193
194
195
# File 'lib/kubes/compiler/dsl/syntax/deployment.rb', line 190

def default_sidecar
  {
    name:  sidecar_name,
    image: sidecar_image,
  }
end

#default_sidecar_nameObject



197
198
199
# 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_specObject



96
97
98
99
100
101
102
103
104
105
106
107
# 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_strategyObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
# 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_templateObject



136
137
138
139
140
141
# File 'lib/kubes/compiler/dsl/syntax/deployment.rb', line 136

def default_template
  {
    metadata: ,
    spec: templateSpec,
  }
end

#default_templateMetadataObject



182
183
184
# File 'lib/kubes/compiler/dsl/syntax/deployment.rb', line 182

def 
  { labels: labels }
end

#default_templateSpecObject



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# 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