github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/schema/v2beta11/config.go (about) 1 /* 2 Copyright 2019 The Skaffold Authors 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v2beta11 18 19 import ( 20 "encoding/json" 21 22 v1 "k8s.io/api/core/v1" 23 "sigs.k8s.io/kustomize/kyaml/yaml" 24 25 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util" 26 ) 27 28 // !!! WARNING !!! This config version is already released, please DO NOT MODIFY the structs in this file. 29 const Version string = "skaffold/v2beta11" 30 31 // NewSkaffoldConfig creates a SkaffoldConfig 32 func NewSkaffoldConfig() util.VersionedConfig { 33 return new(SkaffoldConfig) 34 } 35 36 // SkaffoldConfig holds the fields parsed from the Skaffold configuration file (skaffold.yaml). 37 type SkaffoldConfig struct { 38 // APIVersion is the version of the configuration. 39 APIVersion string `yaml:"apiVersion" yamltags:"required"` 40 41 // Kind is always `Config`. Defaults to `Config`. 42 Kind string `yaml:"kind" yamltags:"required"` 43 44 // Metadata holds additional information about the config. 45 Metadata Metadata `yaml:"metadata,omitempty"` 46 47 // Dependencies describes a list of other required configs for the current config. 48 Dependencies []ConfigDependency `yaml:"requires,omitempty"` 49 50 // Pipeline defines the Build/Test/Deploy phases. 51 Pipeline `yaml:",inline"` 52 53 // Profiles *beta* can override be used to `build`, `test` or `deploy` configuration. 54 Profiles []Profile `yaml:"profiles,omitempty"` 55 } 56 57 // Metadata holds an optional name of the project. 58 type Metadata struct { 59 // Name is an identifier for the project. 60 Name string `yaml:"name,omitempty"` 61 } 62 63 // Pipeline describes a Skaffold pipeline. 64 type Pipeline struct { 65 // Build describes how images are built. 66 Build BuildConfig `yaml:"build,omitempty"` 67 68 // Test describes how images are tested. 69 Test []*TestCase `yaml:"test,omitempty"` 70 71 // Deploy describes how images are deployed. 72 Deploy DeployConfig `yaml:"deploy,omitempty"` 73 74 // PortForward describes user defined resources to port-forward. 75 PortForward []*PortForwardResource `yaml:"portForward,omitempty"` 76 } 77 78 // ConfigDependency describes a dependency on another skaffold configuration. 79 type ConfigDependency struct { 80 // Names describes the names of the required configs. 81 Names []string `yaml:"configs,omitempty"` 82 83 // Path describes the path to the file containing the required configs. 84 Path string `yaml:"path" skaffold:"filepath"` 85 86 // ActiveProfiles describes the list of profiles to activate when resolving the required configs. These profiles must exist in the imported config. 87 ActiveProfiles []ProfileDependency `yaml:"activeProfiles,omitempty"` 88 } 89 90 // ProfileDependency describes a mapping from referenced config profiles to the current config profiles. 91 // If the current config is activated with a profile in this mapping then the dependency configs are also activated with the corresponding mapped profiles. 92 type ProfileDependency struct { 93 // Name describes name of the profile to activate in the dependency config. It should exist in the dependency config. 94 Name string `yaml:"name" yamltags:"required"` 95 96 // ActivatedBy describes a list of profiles in the current config that when activated will also activate the named profile in the dependency config. If empty then the named profile is always activated. 97 ActivatedBy []string `yaml:"activatedBy,omitempty"` 98 } 99 100 func (c *SkaffoldConfig) GetVersion() string { 101 return c.APIVersion 102 } 103 104 // ResourceType describes the Kubernetes resource types used for port forwarding. 105 type ResourceType string 106 107 // PortForwardResource describes a resource to port forward. 108 type PortForwardResource struct { 109 // Type is the Kubernetes type that should be port forwarded. 110 // Acceptable resource types include: `Service`, `Pod` and Controller resource type that has a pod spec: `ReplicaSet`, `ReplicationController`, `Deployment`, `StatefulSet`, `DaemonSet`, `Job`, `CronJob`. 111 Type ResourceType `yaml:"resourceType,omitempty"` 112 113 // Name is the name of the Kubernetes resource to port forward. 114 Name string `yaml:"resourceName,omitempty"` 115 116 // Namespace is the namespace of the resource to port forward. 117 Namespace string `yaml:"namespace,omitempty"` 118 119 // Port is the resource port that will be forwarded. 120 Port util.IntOrString `yaml:"port,omitempty"` 121 122 // Address is the local address to bind to. Defaults to the loopback address 127.0.0.1. 123 Address string `yaml:"address,omitempty"` 124 125 // LocalPort is the local port to forward to. If the port is unavailable, Skaffold will choose a random open port to forward to. *Optional*. 126 LocalPort int `yaml:"localPort,omitempty"` 127 } 128 129 // BuildConfig contains all the configuration for the build steps. 130 type BuildConfig struct { 131 // Artifacts lists the images you're going to be building. 132 Artifacts []*Artifact `yaml:"artifacts,omitempty"` 133 134 // InsecureRegistries is a list of registries declared by the user to be insecure. 135 // These registries will be connected to via HTTP instead of HTTPS. 136 InsecureRegistries []string `yaml:"insecureRegistries,omitempty"` 137 138 // TagPolicy *beta* determines how images are tagged. 139 // A few strategies are provided here, although you most likely won't need to care! 140 // If not specified, it defaults to `gitCommit: {variant: Tags}`. 141 TagPolicy TagPolicy `yaml:"tagPolicy,omitempty"` 142 143 BuildType `yaml:",inline"` 144 } 145 146 // TagPolicy contains all the configuration for the tagging step. 147 type TagPolicy struct { 148 // GitTagger *beta* tags images with the git tag or commit of the artifact's workspace. 149 GitTagger *GitTagger `yaml:"gitCommit,omitempty" yamltags:"oneOf=tag"` 150 151 // ShaTagger *beta* tags images with their sha256 digest. 152 ShaTagger *ShaTagger `yaml:"sha256,omitempty" yamltags:"oneOf=tag"` 153 154 // EnvTemplateTagger *beta* tags images with a configurable template string. 155 EnvTemplateTagger *EnvTemplateTagger `yaml:"envTemplate,omitempty" yamltags:"oneOf=tag"` 156 157 // DateTimeTagger *beta* tags images with the build timestamp. 158 DateTimeTagger *DateTimeTagger `yaml:"dateTime,omitempty" yamltags:"oneOf=tag"` 159 160 // CustomTemplateTagger *beta* tags images with a configurable template string *composed of other taggers*. 161 CustomTemplateTagger *CustomTemplateTagger `yaml:"customTemplate,omitempty" yamltags:"oneOf=tag"` 162 } 163 164 // ShaTagger *beta* tags images with their sha256 digest. 165 type ShaTagger struct{} 166 167 // GitTagger *beta* tags images with the git tag or commit of the artifact's workspace. 168 type GitTagger struct { 169 // Variant determines the behavior of the git tagger. Valid variants are: 170 // `Tags` (default): use git tags or fall back to abbreviated commit hash. 171 // `CommitSha`: use the full git commit sha. 172 // `AbbrevCommitSha`: use the abbreviated git commit sha. 173 // `TreeSha`: use the full tree hash of the artifact workingdir. 174 // `AbbrevTreeSha`: use the abbreviated tree hash of the artifact workingdir. 175 Variant string `yaml:"variant,omitempty"` 176 177 // Prefix adds a fixed prefix to the tag. 178 Prefix string `yaml:"prefix,omitempty"` 179 180 // IgnoreChanges specifies whether to omit the `-dirty` postfix if there are uncommitted changes. 181 IgnoreChanges bool `yaml:"ignoreChanges,omitempty"` 182 } 183 184 // EnvTemplateTagger *beta* tags images with a configurable template string. 185 type EnvTemplateTagger struct { 186 // Template used to produce the image name and tag. 187 // See golang [text/template](https://golang.org/pkg/text/template/). 188 // The template is executed against the current environment, 189 // with those variables injected. 190 // For example: `{{.RELEASE}}`. 191 Template string `yaml:"template,omitempty" yamltags:"required"` 192 } 193 194 // DateTimeTagger *beta* tags images with the build timestamp. 195 type DateTimeTagger struct { 196 // Format formats the date and time. 197 // See [#Time.Format](https://golang.org/pkg/time/#Time.Format). 198 // Defaults to `2006-01-02_15-04-05.999_MST`. 199 Format string `yaml:"format,omitempty"` 200 201 // TimeZone sets the timezone for the date and time. 202 // See [Time.LoadLocation](https://golang.org/pkg/time/#Time.LoadLocation). 203 // Defaults to the local timezone. 204 TimeZone string `yaml:"timezone,omitempty"` 205 } 206 207 // CustomTemplateTagger *beta* tags images with a configurable template string. 208 type CustomTemplateTagger struct { 209 // Template used to produce the image name and tag. 210 // See golang [text/template](https://golang.org/pkg/text/template/). 211 // The template is executed against the provided components with those variables injected. 212 // For example: `{{.DATE}}` where DATE references a TaggerComponent. 213 Template string `yaml:"template,omitempty" yamltags:"required"` 214 215 // Components lists TaggerComponents that the template (see field above) can be executed against. 216 Components []TaggerComponent `yaml:"components,omitempty"` 217 } 218 219 // TaggerComponent *beta* is a component of CustomTemplateTagger. 220 type TaggerComponent struct { 221 // Name is an identifier for the component. 222 Name string `yaml:"name,omitempty"` 223 224 // Component is a tagging strategy to be used in CustomTemplateTagger. 225 Component TagPolicy `yaml:",inline" yamltags:"skipTrim"` 226 } 227 228 // BuildType contains the specific implementation and parameters needed 229 // for the build step. Only one field should be populated. 230 type BuildType struct { 231 // LocalBuild *beta* describes how to do a build on the local docker daemon 232 // and optionally push to a repository. 233 LocalBuild *LocalBuild `yaml:"local,omitempty" yamltags:"oneOf=build"` 234 235 // GoogleCloudBuild *beta* describes how to do a remote build on 236 // [Google Cloud Build](https://cloud.google.com/cloud-build/). 237 GoogleCloudBuild *GoogleCloudBuild `yaml:"googleCloudBuild,omitempty" yamltags:"oneOf=build"` 238 239 // Cluster *beta* describes how to do an on-cluster build. 240 Cluster *ClusterDetails `yaml:"cluster,omitempty" yamltags:"oneOf=build"` 241 } 242 243 // LocalBuild *beta* describes how to do a build on the local docker daemon 244 // and optionally push to a repository. 245 type LocalBuild struct { 246 // Push should images be pushed to a registry. 247 // If not specified, images are pushed only if the current Kubernetes context 248 // connects to a remote cluster. 249 Push *bool `yaml:"push,omitempty"` 250 251 // TryImportMissing whether to attempt to import artifacts from 252 // Docker (either a local or remote registry) if not in the cache. 253 TryImportMissing bool `yaml:"tryImportMissing,omitempty"` 254 255 // UseDockerCLI use `docker` command-line interface instead of Docker Engine APIs. 256 UseDockerCLI bool `yaml:"useDockerCLI,omitempty"` 257 258 // UseBuildkit use BuildKit to build Docker images. If unspecified, uses the Docker default. 259 UseBuildkit *bool `yaml:"useBuildkit,omitempty"` 260 261 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 262 // Defaults to `1`. 263 Concurrency *int `yaml:"concurrency,omitempty"` 264 } 265 266 // GoogleCloudBuild *beta* describes how to do a remote build on 267 // [Google Cloud Build](https://cloud.google.com/cloud-build/docs/). 268 // Docker and Jib artifacts can be built on Cloud Build. The `projectId` needs 269 // to be provided and the currently logged in user should be given permissions to trigger 270 // new builds. 271 type GoogleCloudBuild struct { 272 // ProjectID is the ID of your Cloud Platform Project. 273 // If it is not provided, Skaffold will guess it from the image name. 274 // For example, given the artifact image name `gcr.io/myproject/image`, Skaffold 275 // will use the `myproject` GCP project. 276 ProjectID string `yaml:"projectId,omitempty"` 277 278 // DiskSizeGb is the disk size of the VM that runs the build. 279 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#buildoptions). 280 DiskSizeGb int64 `yaml:"diskSizeGb,omitempty"` 281 282 // MachineType is the type of the VM that runs the build. 283 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#buildoptions). 284 MachineType string `yaml:"machineType,omitempty"` 285 286 // Timeout is the amount of time (in seconds) that this build should be allowed to run. 287 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#resource-build). 288 Timeout string `yaml:"timeout,omitempty"` 289 290 // Logging specifies the logging mode. 291 // Valid modes are: 292 // `LOGGING_UNSPECIFIED`: The service determines the logging mode. 293 // `LEGACY`: Stackdriver logging and Cloud Storage logging are enabled (default). 294 // `GCS_ONLY`: Only Cloud Storage logging is enabled. 295 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#loggingmode). 296 Logging string `yaml:"logging,omitempty"` 297 298 // LogStreamingOption specifies the behavior when writing build logs to Google Cloud Storage. 299 // Valid options are: 300 // `STREAM_DEFAULT`: Service may automatically determine build log streaming behavior. 301 // `STREAM_ON`: Build logs should be streamed to Google Cloud Storage. 302 // `STREAM_OFF`: Build logs should not be streamed to Google Cloud Storage; they will be written when the build is completed. 303 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#logstreamingoption). 304 LogStreamingOption string `yaml:"logStreamingOption,omitempty"` 305 306 // DockerImage is the image that runs a Docker build. 307 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 308 // Defaults to `gcr.io/cloud-builders/docker`. 309 DockerImage string `yaml:"dockerImage,omitempty"` 310 311 // KanikoImage is the image that runs a Kaniko build. 312 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 313 // Defaults to `gcr.io/kaniko-project/executor`. 314 KanikoImage string `yaml:"kanikoImage,omitempty"` 315 316 // MavenImage is the image that runs a Maven build. 317 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 318 // Defaults to `gcr.io/cloud-builders/mvn`. 319 MavenImage string `yaml:"mavenImage,omitempty"` 320 321 // GradleImage is the image that runs a Gradle build. 322 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 323 // Defaults to `gcr.io/cloud-builders/gradle`. 324 GradleImage string `yaml:"gradleImage,omitempty"` 325 326 // PackImage is the image that runs a Cloud Native Buildpacks build. 327 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 328 // Defaults to `gcr.io/k8s-skaffold/pack`. 329 PackImage string `yaml:"packImage,omitempty"` 330 331 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 332 // Defaults to `0`. 333 Concurrency int `yaml:"concurrency,omitempty"` 334 335 // WorkerPool configures a pool of workers to run the build. 336 WorkerPool string `yaml:"workerPool,omitempty"` 337 } 338 339 // KanikoCache configures Kaniko caching. If a cache is specified, Kaniko will 340 // use a remote cache which will speed up builds. 341 type KanikoCache struct { 342 // Repo is a remote repository to store cached layers. If none is specified, one will be 343 // inferred from the image name. See [Kaniko Caching](https://github.com/GoogleContainerTools/kaniko#caching). 344 Repo string `yaml:"repo,omitempty"` 345 // HostPath specifies a path on the host that is mounted to each pod as read only cache volume containing base images. 346 // If set, must exist on each node and prepopulated with kaniko-warmer. 347 HostPath string `yaml:"hostPath,omitempty"` 348 // TTL Cache timeout in hours. 349 TTL string `yaml:"ttl,omitempty"` 350 } 351 352 // ClusterDetails *beta* describes how to do an on-cluster build. 353 type ClusterDetails struct { 354 // HTTPProxy for kaniko pod. 355 HTTPProxy string `yaml:"HTTP_PROXY,omitempty"` 356 357 // HTTPSProxy for kaniko pod. 358 HTTPSProxy string `yaml:"HTTPS_PROXY,omitempty"` 359 360 // PullSecretPath is the path to the Google Cloud service account secret key file. 361 PullSecretPath string `yaml:"pullSecretPath,omitempty"` 362 363 // PullSecretName is the name of the Kubernetes secret for pulling base images 364 // and pushing the final image. If given, the secret needs to contain the Google Cloud 365 // service account secret key under the key `kaniko-secret`. 366 // Defaults to `kaniko-secret`. 367 PullSecretName string `yaml:"pullSecretName,omitempty"` 368 369 // PullSecretMountPath is the path the pull secret will be mounted at within the running container. 370 PullSecretMountPath string `yaml:"pullSecretMountPath,omitempty"` 371 372 // Namespace is the Kubernetes namespace. 373 // Defaults to current namespace in Kubernetes configuration. 374 Namespace string `yaml:"namespace,omitempty"` 375 376 // Timeout is the amount of time (in seconds) that this build is allowed to run. 377 // Defaults to 20 minutes (`20m`). 378 Timeout string `yaml:"timeout,omitempty"` 379 380 // DockerConfig describes how to mount the local Docker configuration into a pod. 381 DockerConfig *DockerConfig `yaml:"dockerConfig,omitempty"` 382 383 // ServiceAccountName describes the Kubernetes service account to use for the pod. 384 // Defaults to 'default'. 385 ServiceAccountName string `yaml:"serviceAccount,omitempty"` 386 387 // Tolerations describes the Kubernetes tolerations for the pod. 388 Tolerations []v1.Toleration `yaml:"tolerations,omitempty"` 389 390 // Annotations describes the Kubernetes annotations for the pod. 391 Annotations map[string]string `yaml:"annotations,omitempty"` 392 393 // RunAsUser defines the UID to request for running the container. 394 // If omitted, no SecurityContext will be specified for the pod and will therefore be inherited 395 // from the service account. 396 RunAsUser *int64 `yaml:"runAsUser,omitempty"` 397 398 // Resources define the resource requirements for the kaniko pod. 399 Resources *ResourceRequirements `yaml:"resources,omitempty"` 400 401 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 402 // Defaults to `0`. 403 Concurrency int `yaml:"concurrency,omitempty"` 404 405 // Volumes defines container mounts for ConfigMap and Secret resources. 406 Volumes []v1.Volume `yaml:"volumes,omitempty"` 407 408 // RandomPullSecret adds a random UUID postfix to the default name of the pull secret to facilitate parallel builds, e.g. kaniko-secretdocker-cfgfd154022-c761-416f-8eb3-cf8258450b85. 409 RandomPullSecret bool `yaml:"randomPullSecret,omitempty"` 410 411 // RandomDockerConfigSecret adds a random UUID postfix to the default name of the docker secret to facilitate parallel builds, e.g. docker-cfgfd154022-c761-416f-8eb3-cf8258450b85. 412 RandomDockerConfigSecret bool `yaml:"randomDockerConfigSecret,omitempty"` 413 } 414 415 // DockerConfig contains information about the docker `config.json` to mount. 416 type DockerConfig struct { 417 // Path is the path to the docker `config.json`. 418 Path string `yaml:"path,omitempty"` 419 420 // SecretName is the Kubernetes secret that contains the `config.json` Docker configuration. 421 // Note that the expected secret type is not 'kubernetes.io/dockerconfigjson' but 'Opaque'. 422 SecretName string `yaml:"secretName,omitempty"` 423 } 424 425 // ResourceRequirements describes the resource requirements for the kaniko pod. 426 type ResourceRequirements struct { 427 // Requests [resource requests](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) for the Kaniko pod. 428 Requests *ResourceRequirement `yaml:"requests,omitempty"` 429 430 // Limits [resource limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) for the Kaniko pod. 431 Limits *ResourceRequirement `yaml:"limits,omitempty"` 432 } 433 434 // ResourceRequirement stores the CPU/Memory requirements for the pod. 435 type ResourceRequirement struct { 436 // CPU the number cores to be used. 437 // For example: `2`, `2.0` or `200m`. 438 CPU string `yaml:"cpu,omitempty"` 439 440 // Memory the amount of memory to allocate to the pod. 441 // For example: `1Gi` or `1000Mi`. 442 Memory string `yaml:"memory,omitempty"` 443 444 // EphemeralStorage the amount of Ephemeral storage to allocate to the pod. 445 // For example: `1Gi` or `1000Mi`. 446 EphemeralStorage string `yaml:"ephemeralStorage,omitempty"` 447 448 // ResourceStorage the amount of resource storage to allocate to the pod. 449 // For example: `1Gi` or `1000Mi`. 450 ResourceStorage string `yaml:"resourceStorage,omitempty"` 451 } 452 453 // TestCase is a list of structure tests to run on images that Skaffold builds. 454 type TestCase struct { 455 // ImageName is the artifact on which to run those tests. 456 // For example: `gcr.io/k8s-skaffold/example`. 457 ImageName string `yaml:"image" yamltags:"required"` 458 459 // StructureTests lists the [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) 460 // to run on that artifact. 461 // For example: `["./test/*"]`. 462 StructureTests []string `yaml:"structureTests,omitempty"` 463 } 464 465 // DeployConfig contains all the configuration needed by the deploy steps. 466 type DeployConfig struct { 467 DeployType `yaml:",inline"` 468 469 // StatusCheckDeadlineSeconds *beta* is the deadline for deployments to stabilize in seconds. 470 StatusCheckDeadlineSeconds int `yaml:"statusCheckDeadlineSeconds,omitempty"` 471 472 // KubeContext is the Kubernetes context that Skaffold should deploy to. 473 // For example: `minikube`. 474 KubeContext string `yaml:"kubeContext,omitempty"` 475 476 // Logs configures how container logs are printed as a result of a deployment. 477 Logs LogsConfig `yaml:"logs,omitempty"` 478 } 479 480 // DeployType contains the specific implementation and parameters needed 481 // for the deploy step. All three deployer types can be used at the same 482 // time for hybrid workflows. 483 type DeployType struct { 484 // HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. 485 HelmDeploy *HelmDeploy `yaml:"helm,omitempty"` 486 487 // KptDeploy *alpha* uses the `kpt` CLI to manage and deploy manifests. 488 KptDeploy *KptDeploy `yaml:"kpt,omitempty"` 489 490 // KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. 491 // You'll need a `kubectl` CLI version installed that's compatible with your cluster. 492 KubectlDeploy *KubectlDeploy `yaml:"kubectl,omitempty"` 493 494 // KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. 495 KustomizeDeploy *KustomizeDeploy `yaml:"kustomize,omitempty"` 496 } 497 498 // KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. 499 // You'll need a `kubectl` CLI version installed that's compatible with your cluster. 500 type KubectlDeploy struct { 501 // Manifests lists the Kubernetes yaml or json manifests. 502 // Defaults to `["k8s/*.yaml"]`. 503 Manifests []string `yaml:"manifests,omitempty" skaffold:"filepath"` 504 505 // RemoteManifests lists Kubernetes manifests in remote clusters. 506 RemoteManifests []string `yaml:"remoteManifests,omitempty"` 507 508 // Flags are additional flags passed to `kubectl`. 509 Flags KubectlFlags `yaml:"flags,omitempty"` 510 511 // DefaultNamespace is the default namespace passed to kubectl on deployment if no other override is given. 512 DefaultNamespace *string `yaml:"defaultNamespace,omitempty"` 513 } 514 515 // KubectlFlags are additional flags passed on the command 516 // line to kubectl either on every command (Global), on creations (Apply) 517 // or deletions (Delete). 518 type KubectlFlags struct { 519 // Global are additional flags passed on every command. 520 Global []string `yaml:"global,omitempty"` 521 522 // Apply are additional flags passed on creations (`kubectl apply`). 523 Apply []string `yaml:"apply,omitempty"` 524 525 // Delete are additional flags passed on deletions (`kubectl delete`). 526 Delete []string `yaml:"delete,omitempty"` 527 528 // DisableValidation passes the `--validate=false` flag to supported 529 // `kubectl` commands when enabled. 530 DisableValidation bool `yaml:"disableValidation,omitempty"` 531 } 532 533 // HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. 534 type HelmDeploy struct { 535 // Releases is a list of Helm releases. 536 Releases []HelmRelease `yaml:"releases,omitempty" yamltags:"required"` 537 538 // Flags are additional option flags that are passed on the command 539 // line to `helm`. 540 Flags HelmDeployFlags `yaml:"flags,omitempty"` 541 } 542 543 // HelmDeployFlags are additional option flags that are passed on the command 544 // line to `helm`. 545 type HelmDeployFlags struct { 546 // Global are additional flags passed on every command. 547 Global []string `yaml:"global,omitempty"` 548 549 // Install are additional flags passed to (`helm install`). 550 Install []string `yaml:"install,omitempty"` 551 552 // Upgrade are additional flags passed to (`helm upgrade`). 553 Upgrade []string `yaml:"upgrade,omitempty"` 554 } 555 556 // KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. 557 type KustomizeDeploy struct { 558 // KustomizePaths is the path to Kustomization files. 559 // Defaults to `["."]`. 560 KustomizePaths []string `yaml:"paths,omitempty" skaffold:"filepath"` 561 562 // Flags are additional flags passed to `kubectl`. 563 Flags KubectlFlags `yaml:"flags,omitempty"` 564 565 // BuildArgs are additional args passed to `kustomize build`. 566 BuildArgs []string `yaml:"buildArgs,omitempty"` 567 568 // DefaultNamespace is the default namespace passed to kubectl on deployment if no other override is given. 569 DefaultNamespace *string `yaml:"defaultNamespace,omitempty"` 570 } 571 572 // KptDeploy *alpha* uses the `kpt` CLI to manage and deploy manifests. 573 type KptDeploy struct { 574 // Dir is the path to the config directory (Required). 575 // By default, the Dir contains the application configurations, 576 // [kustomize config files](https://kubectl.docs.kubernetes.io/pages/examples/kustomize.html) 577 // and [declarative kpt functions](https://googlecontainertools.github.io/kpt/guides/consumer/function/#declarative-run). 578 Dir string `yaml:"dir" yamltags:"required" skaffold:"filepath"` 579 580 // Fn adds additional configurations for `kpt fn`. 581 Fn KptFn `yaml:"fn,omitempty"` 582 583 // Live adds additional configurations for `kpt live`. 584 Live KptLive `yaml:"live,omitempty"` 585 } 586 587 // KptFn adds additional configurations used when calling `kpt fn`. 588 type KptFn struct { 589 // FnPath is the directory to discover the declarative kpt functions. 590 // If not provided, kpt deployer uses `kpt.Dir`. 591 FnPath string `yaml:"fnPath,omitempty" skaffold:"filepath"` 592 593 // Image is a kpt function image to run the configs imperatively. If provided, kpt.fn.fnPath 594 // will be ignored. 595 Image string `yaml:"image,omitempty"` 596 597 // NetworkName is the docker network name to run the kpt function containers (default "bridge"). 598 NetworkName string `yaml:"networkName,omitempty"` 599 600 // GlobalScope sets the global scope for the kpt functions. see `kpt help fn run`. 601 GlobalScope bool `yaml:"globalScope,omitempty"` 602 603 // Network enables network access for the kpt function containers. 604 Network bool `yaml:"network,omitempty"` 605 606 // Mount is a list of storage options to mount to the fn image. 607 Mount []string `yaml:"mount,omitempty"` 608 609 // SinkDir is the directory to where the manipulated resource output is stored. 610 SinkDir string `yaml:"sinkDir,omitempty" skaffold:"filepath"` 611 } 612 613 // KptLive adds additional configurations used when calling `kpt live`. 614 type KptLive struct { 615 // Apply sets the kpt inventory directory. 616 Apply KptApplyInventory `yaml:"apply,omitempty"` 617 618 // Options adds additional configurations for `kpt live apply` commands. 619 Options KptApplyOptions `yaml:"options,omitempty"` 620 } 621 622 // KptApplyInventory sets the kpt inventory directory. 623 type KptApplyInventory struct { 624 // Dir is equivalent to the dir in `kpt live apply <dir>`. If not provided, 625 // kpt deployer will create a hidden directory `.kpt-hydrated` to store the manipulated 626 // resource output and the kpt inventory-template.yaml file. 627 Dir string `yaml:"dir,omitempty"` 628 629 // InventoryID *alpha* is the identifier for a group of applied resources. 630 // This value is only needed when the `kpt live` is working on a pre-applied cluster resources. 631 InventoryID string `yaml:"inventoryID,omitempty"` 632 633 // InventoryNamespace *alpha* sets the inventory namespace. 634 InventoryNamespace string `yaml:"inventoryNamespace,omitempty"` 635 } 636 637 // KptApplyOptions adds additional configurations used when calling `kpt live apply`. 638 type KptApplyOptions struct { 639 // PollPeriod sets for the polling period for resource statuses. Default to 2s. 640 PollPeriod string `yaml:"pollPeriod,omitempty"` 641 642 // PrunePropagationPolicy sets the propagation policy for pruning. 643 // Possible settings are Background, Foreground, Orphan. 644 // Default to "Background". 645 PrunePropagationPolicy string `yaml:"prunePropagationPolicy,omitempty"` 646 647 // PruneTimeout sets the time threshold to wait for all pruned resources to be deleted. 648 PruneTimeout string `yaml:"pruneTimeout,omitempty"` 649 650 // ReconcileTimeout sets the time threshold to wait for all resources to reach the current status. 651 ReconcileTimeout string `yaml:"reconcileTimeout,omitempty"` 652 } 653 654 // HelmRelease describes a helm release to be deployed. 655 type HelmRelease struct { 656 // Name is the name of the Helm release. 657 // It accepts environment variables via the go template syntax. 658 Name string `yaml:"name,omitempty" yamltags:"required"` 659 660 // ChartPath is the path to the Helm chart. 661 ChartPath string `yaml:"chartPath,omitempty" yamltags:"required" skaffold:"filepath"` 662 663 // ValuesFiles are the paths to the Helm `values` files. 664 ValuesFiles []string `yaml:"valuesFiles,omitempty" skaffold:"filepath"` 665 666 // ArtifactOverrides are key value pairs where the 667 // key represents the parameter used in the `--set-string` Helm CLI flag to define a container 668 // image and the value corresponds to artifact i.e. `ImageName` defined in `Build.Artifacts` section. 669 // The resulting command-line is controlled by `ImageStrategy`. 670 ArtifactOverrides util.FlatMap `yaml:"artifactOverrides,omitempty"` 671 672 // Namespace is the Kubernetes namespace. 673 Namespace string `yaml:"namespace,omitempty"` 674 675 // Version is the version of the chart. 676 Version string `yaml:"version,omitempty"` 677 678 // SetValues are key-value pairs. 679 // If present, Skaffold will send `--set` flag to Helm CLI and append all pairs after the flag. 680 SetValues util.FlatMap `yaml:"setValues,omitempty"` 681 682 // SetValueTemplates are key-value pairs. 683 // If present, Skaffold will try to parse the value part of each key-value pair using 684 // environment variables in the system, then send `--set` flag to Helm CLI and append 685 // all parsed pairs after the flag. 686 SetValueTemplates util.FlatMap `yaml:"setValueTemplates,omitempty"` 687 688 // SetFiles are key-value pairs. 689 // If present, Skaffold will send `--set-file` flag to Helm CLI and append all pairs after the flag. 690 SetFiles map[string]string `yaml:"setFiles,omitempty"` 691 692 // CreateNamespace if `true`, Skaffold will send `--create-namespace` flag to Helm CLI. 693 // `--create-namespace` flag is available in Helm since version 3.2. 694 // Defaults is `false`. 695 CreateNamespace *bool `yaml:"createNamespace,omitempty"` 696 697 // Wait if `true`, Skaffold will send `--wait` flag to Helm CLI. 698 // Defaults to `false`. 699 Wait bool `yaml:"wait,omitempty"` 700 701 // RecreatePods if `true`, Skaffold will send `--recreate-pods` flag to Helm CLI 702 // when upgrading a new version of a chart in subsequent dev loop deploy. 703 // Defaults to `false`. 704 RecreatePods bool `yaml:"recreatePods,omitempty"` 705 706 // SkipBuildDependencies should build dependencies be skipped. 707 // Ignored when `remote: true`. 708 SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"` 709 710 // UseHelmSecrets instructs skaffold to use secrets plugin on deployment. 711 UseHelmSecrets bool `yaml:"useHelmSecrets,omitempty"` 712 713 // Remote specifies whether the chart path is remote, or exists on the host filesystem. 714 Remote bool `yaml:"remote,omitempty"` 715 716 // UpgradeOnChange specifies whether to upgrade helm chart on code changes. 717 // Default is `true` when helm chart is local (`remote: false`). 718 // Default is `false` if `remote: true`. 719 UpgradeOnChange *bool `yaml:"upgradeOnChange,omitempty"` 720 721 // Overrides are key-value pairs. 722 // If present, Skaffold will build a Helm `values` file that overrides 723 // the original and use it to call Helm CLI (`--f` flag). 724 Overrides util.HelmOverrides `yaml:"overrides,omitempty"` 725 726 // Packaged parameters for packaging helm chart (`helm package`). 727 Packaged *HelmPackaged `yaml:"packaged,omitempty"` 728 729 // ImageStrategy controls how an `ArtifactOverrides` entry is 730 // turned into `--set-string` Helm CLI flag or flags. 731 ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` 732 } 733 734 // HelmPackaged parameters for packaging helm chart (`helm package`). 735 type HelmPackaged struct { 736 // Version sets the `version` on the chart to this semver version. 737 Version string `yaml:"version,omitempty"` 738 739 // AppVersion sets the `appVersion` on the chart to this version. 740 AppVersion string `yaml:"appVersion,omitempty"` 741 } 742 743 // HelmImageStrategy adds image configurations to the Helm `values` file. 744 type HelmImageStrategy struct { 745 HelmImageConfig `yaml:",inline"` 746 } 747 748 // HelmImageConfig describes an image configuration. 749 type HelmImageConfig struct { 750 // HelmFQNConfig is the image configuration uses the syntax `IMAGE-NAME=IMAGE-REPOSITORY:IMAGE-TAG`. 751 HelmFQNConfig *HelmFQNConfig `yaml:"fqn,omitempty" yamltags:"oneOf=helmImageStrategy"` 752 753 // HelmConventionConfig is the image configuration uses the syntax `IMAGE-NAME.repository=IMAGE-REPOSITORY, IMAGE-NAME.tag=IMAGE-TAG`. 754 HelmConventionConfig *HelmConventionConfig `yaml:"helm,omitempty" yamltags:"oneOf=helmImageStrategy"` 755 } 756 757 // HelmFQNConfig is the image config to use the FullyQualifiedImageName as param to set. 758 type HelmFQNConfig struct { 759 // Property defines the image config. 760 Property string `yaml:"property,omitempty"` 761 } 762 763 // HelmConventionConfig is the image config in the syntax of image.repository and image.tag. 764 type HelmConventionConfig struct { 765 // ExplicitRegistry separates `image.registry` to the image config syntax. Useful for some charts e.g. `postgresql`. 766 ExplicitRegistry bool `yaml:"explicitRegistry,omitempty"` 767 } 768 769 // LogsConfig configures how container logs are printed as a result of a deployment. 770 type LogsConfig struct { 771 // Prefix defines the prefix shown on each log line. Valid values are 772 // `container`: prefix logs lines with the name of the container. 773 // `podAndContainer`: prefix logs lines with the names of the pod and of the container. 774 // `auto`: same as `podAndContainer` except that the pod name is skipped if it's the same as the container name. 775 // `none`: don't add a prefix. 776 // Defaults to `auto`. 777 Prefix string `yaml:"prefix,omitempty"` 778 } 779 780 // Artifact are the items that need to be built, along with the context in which 781 // they should be built. 782 type Artifact struct { 783 // ImageName is the name of the image to be built. 784 // For example: `gcr.io/k8s-skaffold/example`. 785 ImageName string `yaml:"image,omitempty" yamltags:"required"` 786 787 // Workspace is the directory containing the artifact's sources. 788 // Defaults to `.`. 789 Workspace string `yaml:"context,omitempty" skaffold:"filepath"` 790 791 // Sync *beta* lists local files synced to pods instead 792 // of triggering an image build when modified. 793 // If no files are listed, sync all the files and infer the destination. 794 // Defaults to `infer: ["**/*"]`. 795 Sync *Sync `yaml:"sync,omitempty"` 796 797 // ArtifactType describes how to build an artifact. 798 ArtifactType `yaml:",inline"` 799 800 // Dependencies describes build artifacts that this artifact depends on. 801 Dependencies []*ArtifactDependency `yaml:"requires,omitempty"` 802 } 803 804 // Sync *beta* specifies what files to sync into the container. 805 // This is a list of sync rules indicating the intent to sync for source files. 806 // If no files are listed, sync all the files and infer the destination. 807 // Defaults to `infer: ["**/*"]`. 808 type Sync struct { 809 // Manual lists manual sync rules indicating the source and destination. 810 Manual []*SyncRule `yaml:"manual,omitempty" yamltags:"oneOf=sync"` 811 812 // Infer lists file patterns which may be synced into the container 813 // The container destination is inferred by the builder 814 // based on the instructions of a Dockerfile. 815 // Available for docker and kaniko artifacts and custom 816 // artifacts that declare dependencies on a dockerfile. 817 Infer []string `yaml:"infer,omitempty" yamltags:"oneOf=sync"` 818 819 // Auto delegates discovery of sync rules to the build system. 820 // Only available for jib and buildpacks. 821 Auto *bool `yaml:"auto,omitempty" yamltags:"oneOf=sync"` 822 } 823 824 // SyncRule specifies which local files to sync to remote folders. 825 type SyncRule struct { 826 // Src is a glob pattern to match local paths against. 827 // Directories should be delimited by `/` on all platforms. 828 // For example: `"css/**/*.css"`. 829 Src string `yaml:"src,omitempty" yamltags:"required"` 830 831 // Dest is the destination path in the container where the files should be synced to. 832 // For example: `"app/"` 833 Dest string `yaml:"dest,omitempty" yamltags:"required"` 834 835 // Strip specifies the path prefix to remove from the source path when 836 // transplanting the files into the destination folder. 837 // For example: `"css/"` 838 Strip string `yaml:"strip,omitempty"` 839 } 840 841 // Profile is used to override any `build`, `test` or `deploy` configuration. 842 type Profile struct { 843 // Name is a unique profile name. 844 // For example: `profile-prod`. 845 Name string `yaml:"name,omitempty" yamltags:"required"` 846 847 // Activation criteria by which a profile can be auto-activated. 848 // The profile is auto-activated if any one of the activations are triggered. 849 // An activation is triggered if all of the criteria (env, kubeContext, command) are triggered. 850 Activation []Activation `yaml:"activation,omitempty"` 851 852 // Patches lists patches applied to the configuration. 853 // Patches use the JSON patch notation. 854 Patches []JSONPatch `yaml:"patches,omitempty"` 855 856 // Pipeline contains the definitions to replace the default skaffold pipeline. 857 Pipeline `yaml:",inline"` 858 } 859 860 // JSONPatch patch to be applied by a profile. 861 type JSONPatch struct { 862 // Op is the operation carried by the patch: `add`, `remove`, `replace`, `move`, `copy` or `test`. 863 // Defaults to `replace`. 864 Op string `yaml:"op,omitempty"` 865 866 // Path is the position in the yaml where the operation takes place. 867 // For example, this targets the `dockerfile` of the first artifact built. 868 // For example: `/build/artifacts/0/docker/dockerfile`. 869 Path string `yaml:"path,omitempty" yamltags:"required"` 870 871 // From is the source position in the yaml, used for `copy` or `move` operations. 872 From string `yaml:"from,omitempty"` 873 874 // Value is the value to apply. Can be any portion of yaml. 875 Value *util.YamlpatchNode `yaml:"value,omitempty"` 876 } 877 878 // Activation criteria by which a profile is auto-activated. 879 type Activation struct { 880 // Env is a `key=pattern` pair. The profile is auto-activated if an Environment 881 // Variable `key` matches the pattern. If the pattern starts with `!`, activation 882 // happens if the remaining pattern is _not_ matched. The pattern matches if the 883 // Environment Variable value is exactly `pattern`, or the regex `pattern` is 884 // found in it. An empty `pattern` (e.g. `env: "key="`) always only matches if 885 // the Environment Variable is undefined or empty. 886 // For example: `ENV=production` 887 Env string `yaml:"env,omitempty"` 888 889 // KubeContext is a Kubernetes context for which the profile is auto-activated. 890 // For example: `minikube`. 891 KubeContext string `yaml:"kubeContext,omitempty"` 892 893 // Command is a Skaffold command for which the profile is auto-activated. 894 // For example: `dev`. 895 Command string `yaml:"command,omitempty"` 896 } 897 898 // ArtifactType describes how to build an artifact. 899 type ArtifactType struct { 900 // DockerArtifact *beta* describes an artifact built from a Dockerfile. 901 DockerArtifact *DockerArtifact `yaml:"docker,omitempty" yamltags:"oneOf=artifact"` 902 903 // BazelArtifact *beta* requires bazel CLI to be installed and the sources to 904 // contain [Bazel](https://bazel.build/) configuration files. 905 BazelArtifact *BazelArtifact `yaml:"bazel,omitempty" yamltags:"oneOf=artifact"` 906 907 // JibArtifact builds images using the 908 // [Jib plugins for Maven or Gradle](https://github.com/GoogleContainerTools/jib/). 909 JibArtifact *JibArtifact `yaml:"jib,omitempty" yamltags:"oneOf=artifact"` 910 911 // KanikoArtifact builds images using [kaniko](https://github.com/GoogleContainerTools/kaniko). 912 KanikoArtifact *KanikoArtifact `yaml:"kaniko,omitempty" yamltags:"oneOf=artifact"` 913 914 // BuildpackArtifact builds images using [Cloud Native Buildpacks](https://buildpacks.io/). 915 BuildpackArtifact *BuildpackArtifact `yaml:"buildpacks,omitempty" yamltags:"oneOf=artifact"` 916 917 // CustomArtifact *beta* builds images using a custom build script written by the user. 918 CustomArtifact *CustomArtifact `yaml:"custom,omitempty" yamltags:"oneOf=artifact"` 919 } 920 921 // ArtifactDependency describes a specific build dependency for an artifact. 922 type ArtifactDependency struct { 923 // ImageName is a reference to an artifact's image name. 924 ImageName string `yaml:"image" yamltags:"required"` 925 // Alias is a token that is replaced with the image reference in the builder definition files. 926 // For example, the `docker` builder will use the alias as a build-arg key. 927 // Defaults to the value of `image`. 928 Alias string `yaml:"alias,omitempty"` 929 } 930 931 // BuildpackArtifact *alpha* describes an artifact built using [Cloud Native Buildpacks](https://buildpacks.io/). 932 // It can be used to build images out of project's sources without any additional configuration. 933 type BuildpackArtifact struct { 934 // Builder is the builder image used. 935 Builder string `yaml:"builder" yamltags:"required"` 936 937 // RunImage overrides the stack's default run image. 938 RunImage string `yaml:"runImage,omitempty"` 939 940 // Env are environment variables, in the `key=value` form, passed to the build. 941 // Values can use the go template syntax. 942 // For example: `["key1=value1", "key2=value2", "key3={{.ENV_VARIABLE}}"]`. 943 Env []string `yaml:"env,omitempty"` 944 945 // Buildpacks is a list of strings, where each string is a specific buildpack to use with the builder. 946 // If you specify buildpacks the builder image automatic detection will be ignored. These buildpacks will be used to build the Image from your source code. 947 // Order matters. 948 Buildpacks []string `yaml:"buildpacks,omitempty"` 949 950 // TrustBuilder indicates that the builder should be trusted. 951 TrustBuilder bool `yaml:"trustBuilder,omitempty"` 952 953 // ProjectDescriptor is the path to the project descriptor file. 954 // Defaults to `project.toml` if it exists. 955 ProjectDescriptor string `yaml:"projectDescriptor,omitempty"` 956 957 // Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. 958 Dependencies *BuildpackDependencies `yaml:"dependencies,omitempty"` 959 } 960 961 // BuildpackDependencies *alpha* is used to specify dependencies for an artifact built by buildpacks. 962 type BuildpackDependencies struct { 963 // Paths should be set to the file dependencies for this artifact, so that the skaffold file watcher knows when to rebuild and perform file synchronization. 964 Paths []string `yaml:"paths,omitempty" yamltags:"oneOf=dependency"` 965 966 // Ignore specifies the paths that should be ignored by skaffold's file watcher. If a file exists in both `paths` and in `ignore`, it will be ignored, and will be excluded from both rebuilds and file synchronization. 967 // Will only work in conjunction with `paths`. 968 Ignore []string `yaml:"ignore,omitempty"` 969 } 970 971 // CustomArtifact *beta* describes an artifact built from a custom build script 972 // written by the user. It can be used to build images with builders that aren't directly integrated with skaffold. 973 type CustomArtifact struct { 974 // BuildCommand is the command executed to build the image. 975 BuildCommand string `yaml:"buildCommand,omitempty"` 976 // Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. 977 Dependencies *CustomDependencies `yaml:"dependencies,omitempty"` 978 } 979 980 // CustomDependencies *beta* is used to specify dependencies for an artifact built by a custom build script. 981 // Either `dockerfile` or `paths` should be specified for file watching to work as expected. 982 type CustomDependencies struct { 983 // Dockerfile should be set if the artifact is built from a Dockerfile, from which skaffold can determine dependencies. 984 Dockerfile *DockerfileDependency `yaml:"dockerfile,omitempty" yamltags:"oneOf=dependency"` 985 986 // Command represents a custom command that skaffold executes to obtain dependencies. The output of this command *must* be a valid JSON array. 987 Command string `yaml:"command,omitempty" yamltags:"oneOf=dependency"` 988 989 // Paths should be set to the file dependencies for this artifact, so that the skaffold file watcher knows when to rebuild and perform file synchronization. 990 Paths []string `yaml:"paths,omitempty" yamltags:"oneOf=dependency"` 991 992 // Ignore specifies the paths that should be ignored by skaffold's file watcher. If a file exists in both `paths` and in `ignore`, it will be ignored, and will be excluded from both rebuilds and file synchronization. 993 // Will only work in conjunction with `paths`. 994 Ignore []string `yaml:"ignore,omitempty"` 995 } 996 997 // DockerfileDependency *beta* is used to specify a custom build artifact that is built from a Dockerfile. This allows skaffold to determine dependencies from the Dockerfile. 998 type DockerfileDependency struct { 999 // Path locates the Dockerfile relative to workspace. 1000 Path string `yaml:"path,omitempty"` 1001 1002 // BuildArgs are key/value pairs used to resolve values of `ARG` instructions in a Dockerfile. 1003 // Values can be constants or environment variables via the go template syntax. 1004 // For example: `{"key1": "value1", "key2": "value2", "key3": "'{{.ENV_VARIABLE}}'"}`. 1005 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 1006 } 1007 1008 // KanikoArtifact describes an artifact built from a Dockerfile, 1009 // with kaniko. 1010 type KanikoArtifact struct { 1011 1012 // Cleanup to clean the filesystem at the end of the build. 1013 Cleanup bool `yaml:"cleanup,omitempty"` 1014 1015 // Insecure if you want to push images to a plain HTTP registry. 1016 Insecure bool `yaml:"insecure,omitempty"` 1017 1018 // InsecurePull if you want to pull images from a plain HTTP registry. 1019 InsecurePull bool `yaml:"insecurePull,omitempty"` 1020 1021 // NoPush if you only want to build the image, without pushing to a registry. 1022 NoPush bool `yaml:"noPush,omitempty"` 1023 1024 // Force building outside of a container. 1025 Force bool `yaml:"force,omitempty"` 1026 1027 // LogTimestamp to add timestamps to log format. 1028 LogTimestamp bool `yaml:"logTimestamp,omitempty"` 1029 1030 // Reproducible is used to strip timestamps out of the built image. 1031 Reproducible bool `yaml:"reproducible,omitempty"` 1032 1033 // SingleSnapshot is takes a single snapshot of the filesystem at the end of the build. 1034 // So only one layer will be appended to the base image. 1035 SingleSnapshot bool `yaml:"singleSnapshot,omitempty"` 1036 1037 // SkipTLS skips TLS certificate validation when pushing to a registry. 1038 SkipTLS bool `yaml:"skipTLS,omitempty"` 1039 1040 // SkipTLSVerifyPull skips TLS certificate validation when pulling from a registry. 1041 SkipTLSVerifyPull bool `yaml:"skipTLSVerifyPull,omitempty"` 1042 1043 // SkipUnusedStages builds only used stages if defined to true. 1044 // Otherwise it builds by default all stages, even the unnecessaries ones until it reaches the target stage / end of Dockerfile. 1045 SkipUnusedStages bool `yaml:"skipUnusedStages,omitempty"` 1046 1047 // UseNewRun to Use the experimental run implementation for detecting changes without requiring file system snapshots. 1048 // In some cases, this may improve build performance by 75%. 1049 UseNewRun bool `yaml:"useNewRun,omitempty"` 1050 1051 // WhitelistVarRun is used to ignore `/var/run` when taking image snapshot. 1052 // Set it to false to preserve /var/run/* in destination image. 1053 WhitelistVarRun bool `yaml:"whitelistVarRun,omitempty"` 1054 1055 // DockerfilePath locates the Dockerfile relative to workspace. 1056 // Defaults to `Dockerfile`. 1057 DockerfilePath string `yaml:"dockerfile,omitempty"` 1058 1059 // Target is to indicate which build stage is the target build stage. 1060 Target string `yaml:"target,omitempty"` 1061 1062 // InitImage is the image used to run init container which mounts kaniko context. 1063 InitImage string `yaml:"initImage,omitempty"` 1064 1065 // Image is the Docker image used by the Kaniko pod. 1066 // Defaults to the latest released version of `gcr.io/kaniko-project/executor`. 1067 Image string `yaml:"image,omitempty"` 1068 1069 // DigestFile to specify a file in the container. This file will receive the digest of a built image. 1070 // This can be used to automatically track the exact image built by kaniko. 1071 DigestFile string `yaml:"digestFile,omitempty"` 1072 1073 // ImageNameWithDigestFile specify a file to save the image name with digest of the built image to. 1074 ImageNameWithDigestFile string `yaml:"imageNameWithDigestFile,omitempty"` 1075 1076 // LogFormat <text|color|json> to set the log format. 1077 LogFormat string `yaml:"logFormat,omitempty"` 1078 1079 // OCILayoutPath is to specify a directory in the container where the OCI image layout of a built image will be placed. 1080 // This can be used to automatically track the exact image built by kaniko. 1081 OCILayoutPath string `yaml:"ociLayoutPath,omitempty"` 1082 1083 // RegistryMirror if you want to use a registry mirror instead of default `index.docker.io`. 1084 RegistryMirror string `yaml:"registryMirror,omitempty"` 1085 1086 // SnapshotMode is how Kaniko will snapshot the filesystem. 1087 SnapshotMode string `yaml:"snapshotMode,omitempty"` 1088 1089 // TarPath is path to save the image as a tarball at path instead of pushing the image. 1090 TarPath string `yaml:"tarPath,omitempty"` 1091 1092 // Verbosity <panic|fatal|error|warn|info|debug|trace> to set the logging level. 1093 Verbosity string `yaml:"verbosity,omitempty"` 1094 1095 // InsecureRegistry is to use plain HTTP requests when accessing a registry. 1096 InsecureRegistry []string `yaml:"insecureRegistry,omitempty"` 1097 1098 // SkipTLSVerifyRegistry skips TLS certificate validation when accessing a registry. 1099 SkipTLSVerifyRegistry []string `yaml:"skipTLSVerifyRegistry,omitempty"` 1100 1101 // Env are environment variables passed to the kaniko pod. 1102 // It also accepts environment variables via the go template syntax. 1103 // For example: `[{"name": "key1", "value": "value1"}, {"name": "key2", "value": "value2"}, {"name": "key3", "value": "'{{.ENV_VARIABLE}}'"}]`. 1104 Env []v1.EnvVar `yaml:"env,omitempty"` 1105 1106 // Cache configures Kaniko caching. If a cache is specified, Kaniko will 1107 // use a remote cache which will speed up builds. 1108 Cache *KanikoCache `yaml:"cache,omitempty"` 1109 1110 // RegistryCertificate is to provide a certificate for TLS communication with a given registry. 1111 // my.registry.url: /path/to/the/certificate.cert is the expected format. 1112 RegistryCertificate map[string]*string `yaml:"registryCertificate,omitempty"` 1113 1114 // Label key: value to set some metadata to the final image. 1115 // This is equivalent as using the LABEL within the Dockerfile. 1116 Label map[string]*string `yaml:"label,omitempty"` 1117 1118 // BuildArgs are arguments passed to the docker build. 1119 // It also accepts environment variables and generated values via the go template syntax. 1120 // Exposed generated values: IMAGE_REPO, IMAGE_NAME, IMAGE_TAG. 1121 // For example: `{"key1": "value1", "key2": "value2", "key3": "'{{.ENV_VARIABLE}}'"}`. 1122 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 1123 1124 // VolumeMounts are volume mounts passed to kaniko pod. 1125 VolumeMounts []v1.VolumeMount `yaml:"volumeMounts,omitempty"` 1126 } 1127 1128 // DockerArtifact describes an artifact built from a Dockerfile, 1129 // usually using `docker build`. 1130 type DockerArtifact struct { 1131 // DockerfilePath locates the Dockerfile relative to workspace. 1132 // Defaults to `Dockerfile`. 1133 DockerfilePath string `yaml:"dockerfile,omitempty"` 1134 1135 // Target is the Dockerfile target name to build. 1136 Target string `yaml:"target,omitempty"` 1137 1138 // BuildArgs are arguments passed to the docker build. 1139 // For example: `{"key1": "value1", "key2": "value2"}`. 1140 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 1141 1142 // NetworkMode is passed through to docker and overrides the 1143 // network configuration of docker builder. If unset, use whatever 1144 // is configured in the underlying docker daemon. Valid modes are 1145 // `host`: use the host's networking stack. 1146 // `bridge`: use the bridged network configuration. 1147 // `container:<name|id>`: reuse another container's network stack. 1148 // `none`: no networking in the container. 1149 NetworkMode string `yaml:"network,omitempty"` 1150 1151 // CacheFrom lists the Docker images used as cache sources. 1152 // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. 1153 CacheFrom []string `yaml:"cacheFrom,omitempty"` 1154 1155 // NoCache used to pass in --no-cache to docker build to prevent caching. 1156 NoCache bool `yaml:"noCache,omitempty"` 1157 1158 // Squash is used to pass in --squash to docker build to squash docker image layers into single layer. 1159 Squash bool `yaml:"squash,omitempty"` 1160 1161 // Secret contains information about a local secret passed to `docker build`, 1162 // along with optional destination information. 1163 Secret *DockerSecret `yaml:"secret,omitempty"` 1164 1165 // SSH is used to pass in --ssh to docker build to use SSH agent. Format is "default|<id>[=<socket>|<key>[,<key>]]". 1166 SSH string `yaml:"ssh,omitempty"` 1167 } 1168 1169 // DockerSecret contains information about a local secret passed to `docker build`, 1170 // along with optional destination information. 1171 type DockerSecret struct { 1172 // ID is the id of the secret. 1173 ID string `yaml:"id,omitempty" yamltags:"required"` 1174 1175 // Source is the path to the secret on the host machine. 1176 Source string `yaml:"src,omitempty"` 1177 1178 // Destination is the path in the container to mount the secret. 1179 Destination string `yaml:"dst,omitempty"` 1180 } 1181 1182 // BazelArtifact describes an artifact built with [Bazel](https://bazel.build/). 1183 type BazelArtifact struct { 1184 // BuildTarget is the `bazel build` target to run. 1185 // For example: `//:skaffold_example.tar`. 1186 BuildTarget string `yaml:"target,omitempty" yamltags:"required"` 1187 1188 // BuildArgs are additional args to pass to `bazel build`. 1189 // For example: `["-flag", "--otherflag"]`. 1190 BuildArgs []string `yaml:"args,omitempty"` 1191 } 1192 1193 // JibArtifact builds images using the 1194 // [Jib plugins for Maven and Gradle](https://github.com/GoogleContainerTools/jib/). 1195 type JibArtifact struct { 1196 // Project selects which sub-project to build for multi-module builds. 1197 Project string `yaml:"project,omitempty"` 1198 1199 // Flags are additional build flags passed to the builder. 1200 // For example: `["--no-build-cache"]`. 1201 Flags []string `yaml:"args,omitempty"` 1202 1203 // Type the Jib builder type; normally determined automatically. Valid types are 1204 // `maven`: for Maven. 1205 // `gradle`: for Gradle. 1206 Type string `yaml:"type,omitempty"` 1207 1208 // BaseImage overrides the configured jib base image. 1209 BaseImage string `yaml:"fromImage,omitempty"` 1210 } 1211 1212 // UnmarshalYAML provides a custom unmarshaller to deal with 1213 // https://github.com/GoogleContainerTools/skaffold/issues/4175 1214 func (clusterDetails *ClusterDetails) UnmarshalYAML(value *yaml.Node) error { 1215 // We do this as follows 1216 // 1. We zero out the fields in the node that require custom processing 1217 // 2. We unmarshal all the non special fields using the aliased type resource 1218 // we use an alias type to avoid recursion caused by invoking this function infinitely 1219 // 3. We deserialize the special fields as required. 1220 type ClusterDetailsForUnmarshaling ClusterDetails 1221 1222 volumes, remaining, err := util.UnmarshalClusterVolumes(value) 1223 1224 if err != nil { 1225 return err 1226 } 1227 1228 // Unmarshal the remaining values 1229 aux := (*ClusterDetailsForUnmarshaling)(clusterDetails) 1230 err = yaml.Unmarshal(remaining, aux) 1231 1232 if err != nil { 1233 return err 1234 } 1235 1236 clusterDetails.Volumes = volumes 1237 return nil 1238 } 1239 1240 // UnmarshalYAML provides a custom unmarshaller to deal with 1241 // https://github.com/GoogleContainerTools/skaffold/issues/4175 1242 func (ka *KanikoArtifact) UnmarshalYAML(value *yaml.Node) error { 1243 // We do this as follows 1244 // 1. We zero out the fields in the node that require custom processing 1245 // 2. We unmarshal all the non special fields using the aliased type resource 1246 // we use an alias type to avoid recursion caused by invoking this function infinitely 1247 // 3. We deserialize the special fields as required. 1248 type KanikoArtifactForUnmarshaling KanikoArtifact 1249 1250 mounts, remaining, err := util.UnmarshalKanikoArtifact(value) 1251 1252 if err != nil { 1253 return err 1254 } 1255 1256 // Unmarshal the remaining values 1257 aux := (*KanikoArtifactForUnmarshaling)(ka) 1258 err = yaml.Unmarshal(remaining, aux) 1259 1260 if err != nil { 1261 return err 1262 } 1263 1264 ka.VolumeMounts = mounts 1265 return nil 1266 } 1267 1268 // MarshalYAML provides a custom marshaller to deal with 1269 // https://github.com/GoogleContainerTools/skaffold/issues/4175 1270 func (clusterDetails *ClusterDetails) MarshalYAML() (interface{}, error) { 1271 // We do this as follows 1272 // 1. We zero out the fields in the node that require custom processing 1273 // 2. We marshall all the non special fields using the aliased type resource 1274 // we use an alias type to avoid recursion caused by invoking this function infinitely 1275 // 3. We unmarshal to a map 1276 // 4. We marshal the special fields to json and unmarshal to a map 1277 // * This leverages the json struct annotations to marshal as expected 1278 // 5. We combine the two maps and return 1279 type ClusterDetailsForUnmarshaling ClusterDetails 1280 1281 // Marshal volumes to a list. Use json because the Kubernetes resources have json annotations. 1282 volumes := clusterDetails.Volumes 1283 1284 j, err := json.Marshal(volumes) 1285 1286 if err != nil { 1287 return err, nil 1288 } 1289 1290 vList := []interface{}{} 1291 1292 if err := json.Unmarshal(j, &vList); err != nil { 1293 return nil, err 1294 } 1295 1296 // Make a deep copy of clusterDetails because we need to zero out volumes and we don't want to modify the 1297 // current object. 1298 aux := &ClusterDetailsForUnmarshaling{} 1299 1300 b, err := json.Marshal(clusterDetails) 1301 1302 if err != nil { 1303 return nil, err 1304 } 1305 1306 if err := json.Unmarshal(b, aux); err != nil { 1307 return nil, err 1308 } 1309 1310 aux.Volumes = nil 1311 1312 marshaled, err := yaml.Marshal(aux) 1313 1314 if err != nil { 1315 return nil, err 1316 } 1317 1318 m := map[string]interface{}{} 1319 1320 err = yaml.Unmarshal(marshaled, m) 1321 1322 if len(vList) > 0 { 1323 m["volumes"] = vList 1324 } 1325 return m, err 1326 } 1327 1328 // MarshalYAML provides a custom marshaller to deal with 1329 // https://github.com/GoogleContainerTools/skaffold/issues/4175 1330 func (ka *KanikoArtifact) MarshalYAML() (interface{}, error) { 1331 // We do this as follows 1332 // 1. We zero out the fields in the node that require custom processing 1333 // 2. We marshal all the non special fields using the aliased type resource 1334 // we use an alias type to avoid recursion caused by invoking this function infinitely 1335 // 3. We unmarshal to a map 1336 // 4. We marshal the special fields to json and unmarshal to a map 1337 // * This leverages the json struct annotations to marshal as expected 1338 // 5. We combine the two maps and return 1339 type KanikoArtifactForUnmarshaling KanikoArtifact 1340 1341 // Marshal volumes to a map. User json because the Kubernetes resources have json annotations. 1342 volumeMounts := ka.VolumeMounts 1343 1344 j, err := json.Marshal(volumeMounts) 1345 1346 if err != nil { 1347 return err, nil 1348 } 1349 1350 vList := []interface{}{} 1351 1352 if err := json.Unmarshal(j, &vList); err != nil { 1353 return nil, err 1354 } 1355 1356 // Make a deep copy of kanikoArtifact because we need to zero out volumeMounts and we don't want to modify the 1357 // current object. 1358 aux := &KanikoArtifactForUnmarshaling{} 1359 1360 b, err := json.Marshal(ka) 1361 1362 if err != nil { 1363 return nil, err 1364 } 1365 1366 if err := json.Unmarshal(b, aux); err != nil { 1367 return nil, err 1368 } 1369 aux.VolumeMounts = nil 1370 1371 marshaled, err := yaml.Marshal(aux) 1372 1373 if err != nil { 1374 return nil, err 1375 } 1376 1377 m := map[string]interface{}{} 1378 1379 err = yaml.Unmarshal(marshaled, m) 1380 1381 if len(vList) > 0 { 1382 m["volumeMounts"] = vList 1383 } 1384 return m, err 1385 }