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