github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/schema/v2beta5/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 v2beta5 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 22 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util" 23 ) 24 25 // !!! WARNING !!! This config version is already released, please DO NOT MODIFY the structs in this file. 26 const Version string = "skaffold/v2beta5" 27 28 // NewSkaffoldConfig creates a SkaffoldConfig 29 func NewSkaffoldConfig() util.VersionedConfig { 30 return new(SkaffoldConfig) 31 } 32 33 // SkaffoldConfig holds the fields parsed from the Skaffold configuration file (skaffold.yaml). 34 type SkaffoldConfig struct { 35 // APIVersion is the version of the configuration. 36 APIVersion string `yaml:"apiVersion" yamltags:"required"` 37 38 // Kind is always `Config`. Defaults to `Config`. 39 Kind string `yaml:"kind" yamltags:"required"` 40 41 // Metadata holds additional information about the config. 42 Metadata Metadata `yaml:"metadata,omitempty"` 43 44 // Pipeline defines the Build/Test/Deploy phases. 45 Pipeline `yaml:",inline"` 46 47 // Profiles *beta* can override be used to `build`, `test` or `deploy` configuration. 48 Profiles []Profile `yaml:"profiles,omitempty"` 49 } 50 51 // Metadata holds an optional name of the project. 52 type Metadata struct { 53 // Name is an identifier for the project. 54 Name string `yaml:"name,omitempty"` 55 } 56 57 // Pipeline describes a Skaffold pipeline. 58 type Pipeline struct { 59 // Build describes how images are built. 60 Build BuildConfig `yaml:"build,omitempty"` 61 62 // Test describes how images are tested. 63 Test []*TestCase `yaml:"test,omitempty"` 64 65 // Deploy describes how images are deployed. 66 Deploy DeployConfig `yaml:"deploy,omitempty"` 67 68 // PortForward describes user defined resources to port-forward. 69 PortForward []*PortForwardResource `yaml:"portForward,omitempty"` 70 } 71 72 func (c *SkaffoldConfig) GetVersion() string { 73 return c.APIVersion 74 } 75 76 // ResourceType describes the Kubernetes resource types used for port forwarding. 77 type ResourceType string 78 79 // PortForwardResource describes a resource to port forward. 80 type PortForwardResource struct { 81 // Type is the Kubernetes type that should be port forwarded. 82 // Acceptable resource types include: `Service`, `Pod` and Controller resource type that has a pod spec: `ReplicaSet`, `ReplicationController`, `Deployment`, `StatefulSet`, `DaemonSet`, `Job`, `CronJob`. 83 Type ResourceType `yaml:"resourceType,omitempty"` 84 85 // Name is the name of the Kubernetes resource to port forward. 86 Name string `yaml:"resourceName,omitempty"` 87 88 // Namespace is the namespace of the resource to port forward. 89 Namespace string `yaml:"namespace,omitempty"` 90 91 // Port is the resource port that will be forwarded. 92 Port int `yaml:"port,omitempty"` 93 94 // Address is the local address to bind to. Defaults to the loopback address 127.0.0.1. 95 Address string `yaml:"address,omitempty"` 96 97 // LocalPort is the local port to forward to. If the port is unavailable, Skaffold will choose a random open port to forward to. *Optional*. 98 LocalPort int `yaml:"localPort,omitempty"` 99 } 100 101 // BuildConfig contains all the configuration for the build steps. 102 type BuildConfig struct { 103 // Artifacts lists the images you're going to be building. 104 Artifacts []*Artifact `yaml:"artifacts,omitempty"` 105 106 // InsecureRegistries is a list of registries declared by the user to be insecure. 107 // These registries will be connected to via HTTP instead of HTTPS. 108 InsecureRegistries []string `yaml:"insecureRegistries,omitempty"` 109 110 // TagPolicy *beta* determines how images are tagged. 111 // A few strategies are provided here, although you most likely won't need to care! 112 // If not specified, it defaults to `gitCommit: {variant: Tags}`. 113 TagPolicy TagPolicy `yaml:"tagPolicy,omitempty"` 114 115 BuildType `yaml:",inline"` 116 } 117 118 // TagPolicy contains all the configuration for the tagging step. 119 type TagPolicy struct { 120 // GitTagger *beta* tags images with the git tag or commit of the artifact's workspace. 121 GitTagger *GitTagger `yaml:"gitCommit,omitempty" yamltags:"oneOf=tag"` 122 123 // ShaTagger *beta* tags images with their sha256 digest. 124 ShaTagger *ShaTagger `yaml:"sha256,omitempty" yamltags:"oneOf=tag"` 125 126 // EnvTemplateTagger *beta* tags images with a configurable template string. 127 EnvTemplateTagger *EnvTemplateTagger `yaml:"envTemplate,omitempty" yamltags:"oneOf=tag"` 128 129 // DateTimeTagger *beta* tags images with the build timestamp. 130 DateTimeTagger *DateTimeTagger `yaml:"dateTime,omitempty" yamltags:"oneOf=tag"` 131 } 132 133 // ShaTagger *beta* tags images with their sha256 digest. 134 type ShaTagger struct{} 135 136 // GitTagger *beta* tags images with the git tag or commit of the artifact's workspace. 137 type GitTagger struct { 138 // Variant determines the behavior of the git tagger. Valid variants are: 139 // `Tags` (default): use git tags or fall back to abbreviated commit hash. 140 // `CommitSha`: use the full git commit sha. 141 // `AbbrevCommitSha`: use the abbreviated git commit sha. 142 // `TreeSha`: use the full tree hash of the artifact workingdir. 143 // `AbbrevTreeSha`: use the abbreviated tree hash of the artifact workingdir. 144 Variant string `yaml:"variant,omitempty"` 145 146 // Prefix adds a fixed prefix to the tag. 147 Prefix string `yaml:"prefix,omitempty"` 148 } 149 150 // EnvTemplateTagger *beta* tags images with a configurable template string. 151 type EnvTemplateTagger struct { 152 // Template used to produce the image name and tag. 153 // See golang [text/template](https://golang.org/pkg/text/template/). 154 // The template is executed against the current environment, 155 // with those variables injected: 156 // IMAGE_NAME | Name of the image being built, as supplied in the artifacts section. 157 // For example: `{{.RELEASE}}-{{.IMAGE_NAME}}`. 158 Template string `yaml:"template,omitempty" yamltags:"required"` 159 } 160 161 // DateTimeTagger *beta* tags images with the build timestamp. 162 type DateTimeTagger struct { 163 // Format formats the date and time. 164 // See [#Time.Format](https://golang.org/pkg/time/#Time.Format). 165 // Defaults to `2006-01-02_15-04-05.999_MST`. 166 Format string `yaml:"format,omitempty"` 167 168 // TimeZone sets the timezone for the date and time. 169 // See [Time.LoadLocation](https://golang.org/pkg/time/#Time.LoadLocation). 170 // Defaults to the local timezone. 171 TimeZone string `yaml:"timezone,omitempty"` 172 } 173 174 // BuildType contains the specific implementation and parameters needed 175 // for the build step. Only one field should be populated. 176 type BuildType struct { 177 // LocalBuild *beta* describes how to do a build on the local docker daemon 178 // and optionally push to a repository. 179 LocalBuild *LocalBuild `yaml:"local,omitempty" yamltags:"oneOf=build"` 180 181 // GoogleCloudBuild *beta* describes how to do a remote build on 182 // [Google Cloud Build](https://cloud.google.com/cloud-build/). 183 GoogleCloudBuild *GoogleCloudBuild `yaml:"googleCloudBuild,omitempty" yamltags:"oneOf=build"` 184 185 // Cluster *beta* describes how to do an on-cluster build. 186 Cluster *ClusterDetails `yaml:"cluster,omitempty" yamltags:"oneOf=build"` 187 } 188 189 // LocalBuild *beta* describes how to do a build on the local docker daemon 190 // and optionally push to a repository. 191 type LocalBuild struct { 192 // Push should images be pushed to a registry. 193 // If not specified, images are pushed only if the current Kubernetes context 194 // connects to a remote cluster. 195 Push *bool `yaml:"push,omitempty"` 196 197 // UseDockerCLI use `docker` command-line interface instead of Docker Engine APIs. 198 UseDockerCLI bool `yaml:"useDockerCLI,omitempty"` 199 200 // UseBuildkit use BuildKit to build Docker images. If unspecified, uses the Docker default. 201 UseBuildkit *bool `yaml:"useBuildkit,omitempty"` 202 203 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 204 // Defaults to `1`. 205 Concurrency *int `yaml:"concurrency,omitempty"` 206 } 207 208 // GoogleCloudBuild *beta* describes how to do a remote build on 209 // [Google Cloud Build](https://cloud.google.com/cloud-build/docs/). 210 // Docker and Jib artifacts can be built on Cloud Build. The `projectId` needs 211 // to be provided and the currently logged in user should be given permissions to trigger 212 // new builds. 213 type GoogleCloudBuild struct { 214 // ProjectID is the ID of your Cloud Platform Project. 215 // If it is not provided, Skaffold will guess it from the image name. 216 // For example, given the artifact image name `gcr.io/myproject/image`, Skaffold 217 // will use the `myproject` GCP project. 218 ProjectID string `yaml:"projectId,omitempty"` 219 220 // DiskSizeGb is the disk size of the VM that runs the build. 221 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#buildoptions). 222 DiskSizeGb int64 `yaml:"diskSizeGb,omitempty"` 223 224 // MachineType is the type of the VM that runs the build. 225 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#buildoptions). 226 MachineType string `yaml:"machineType,omitempty"` 227 228 // Timeout is the amount of time (in seconds) that this build should be allowed to run. 229 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#resource-build). 230 Timeout string `yaml:"timeout,omitempty"` 231 232 // Logging specifies the logging mode. 233 // Valid modes are: 234 // `LOGGING_UNSPECIFIED`: The service determines the logging mode. 235 // `LEGACY`: Stackdriver logging and Cloud Storage logging are enabled (default). 236 // `GCS_ONLY`: Only Cloud Storage logging is enabled. 237 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#loggingmode). 238 Logging string `yaml:"logging,omitempty"` 239 240 // LogStreamingOption specifies the behavior when writing build logs to Google Cloud Storage. 241 // Valid options are: 242 // `STREAM_DEFAULT`: Service may automatically determine build log streaming behavior. 243 // `STREAM_ON`: Build logs should be streamed to Google Cloud Storage. 244 // `STREAM_OFF`: Build logs should not be streamed to Google Cloud Storage; they will be written when the build is completed. 245 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#logstreamingoption). 246 LogStreamingOption string `yaml:"logStreamingOption,omitempty"` 247 248 // DockerImage is the image that runs a Docker build. 249 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 250 // Defaults to `gcr.io/cloud-builders/docker`. 251 DockerImage string `yaml:"dockerImage,omitempty"` 252 253 // KanikoImage is the image that runs a Kaniko build. 254 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 255 // Defaults to `gcr.io/kaniko-project/executor`. 256 KanikoImage string `yaml:"kanikoImage,omitempty"` 257 258 // MavenImage is the image that runs a Maven build. 259 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 260 // Defaults to `gcr.io/cloud-builders/mvn`. 261 MavenImage string `yaml:"mavenImage,omitempty"` 262 263 // GradleImage is the image that runs a Gradle build. 264 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 265 // Defaults to `gcr.io/cloud-builders/gradle`. 266 GradleImage string `yaml:"gradleImage,omitempty"` 267 268 // PackImage is the image that runs a Cloud Native Buildpacks build. 269 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 270 // Defaults to `gcr.io/k8s-skaffold/pack`. 271 PackImage string `yaml:"packImage,omitempty"` 272 273 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 274 // Defaults to `0`. 275 Concurrency int `yaml:"concurrency,omitempty"` 276 } 277 278 // KanikoCache configures Kaniko caching. If a cache is specified, Kaniko will 279 // use a remote cache which will speed up builds. 280 type KanikoCache struct { 281 // Repo is a remote repository to store cached layers. If none is specified, one will be 282 // inferred from the image name. See [Kaniko Caching](https://github.com/GoogleContainerTools/kaniko#caching). 283 Repo string `yaml:"repo,omitempty"` 284 // HostPath specifies a path on the host that is mounted to each pod as read only cache volume containing base images. 285 // If set, must exist on each node and prepopulated with kaniko-warmer. 286 HostPath string `yaml:"hostPath,omitempty"` 287 } 288 289 // ClusterDetails *beta* describes how to do an on-cluster build. 290 type ClusterDetails struct { 291 // HTTPProxy for kaniko pod. 292 HTTPProxy string `yaml:"HTTP_PROXY,omitempty"` 293 294 // HTTPSProxy for kaniko pod. 295 HTTPSProxy string `yaml:"HTTPS_PROXY,omitempty"` 296 297 // PullSecretPath is the path to the Google Cloud service account secret key file. 298 PullSecretPath string `yaml:"pullSecretPath,omitempty"` 299 300 // PullSecretName is the name of the Kubernetes secret for pulling base images 301 // and pushing the final image. If given, the secret needs to contain the Google Cloud 302 // service account secret key under the key `kaniko-secret`. 303 // Defaults to `kaniko-secret`. 304 PullSecretName string `yaml:"pullSecretName,omitempty"` 305 306 // PullSecretMountPath is the path the pull secret will be mounted at within the running container. 307 PullSecretMountPath string `yaml:"pullSecretMountPath,omitempty"` 308 309 // Namespace is the Kubernetes namespace. 310 // Defaults to current namespace in Kubernetes configuration. 311 Namespace string `yaml:"namespace,omitempty"` 312 313 // Timeout is the amount of time (in seconds) that this build is allowed to run. 314 // Defaults to 20 minutes (`20m`). 315 Timeout string `yaml:"timeout,omitempty"` 316 317 // DockerConfig describes how to mount the local Docker configuration into a pod. 318 DockerConfig *DockerConfig `yaml:"dockerConfig,omitempty"` 319 320 // ServiceAccountName describes the Kubernetes service account to use for the pod. 321 // Defaults to 'default'. 322 ServiceAccountName string `yaml:"serviceAccount,omitempty"` 323 324 // Tolerations describes the Kubernetes tolerations for the pod. 325 Tolerations []v1.Toleration `yaml:"tolerations,omitempty"` 326 327 // Annotations describes the Kubernetes annotations for the pod. 328 Annotations map[string]string `yaml:"annotations,omitempty"` 329 330 // RunAsUser defines the UID to request for running the container. 331 // If omitted, no SecurityContext will be specified for the pod and will therefore be inherited 332 // from the service account. 333 RunAsUser *int64 `yaml:"runAsUser,omitempty"` 334 335 // Resources define the resource requirements for the kaniko pod. 336 Resources *ResourceRequirements `yaml:"resources,omitempty"` 337 338 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 339 // Defaults to `0`. 340 Concurrency int `yaml:"concurrency,omitempty"` 341 342 // Volumes defines container mounts for ConfigMap and Secret resources. 343 Volumes []v1.Volume `yaml:"volumes,omitempty"` 344 345 // 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. 346 RandomPullSecret bool `yaml:"randomPullSecret,omitempty"` 347 348 // 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. 349 RandomDockerConfigSecret bool `yaml:"randomDockerConfigSecret,omitempty"` 350 } 351 352 // DockerConfig contains information about the docker `config.json` to mount. 353 type DockerConfig struct { 354 // Path is the path to the docker `config.json`. 355 Path string `yaml:"path,omitempty"` 356 357 // SecretName is the Kubernetes secret that contains the `config.json` Docker configuration. 358 // Note that the expected secret type is not 'kubernetes.io/dockerconfigjson' but 'Opaque'. 359 SecretName string `yaml:"secretName,omitempty"` 360 } 361 362 // ResourceRequirements describes the resource requirements for the kaniko pod. 363 type ResourceRequirements struct { 364 // 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. 365 Requests *ResourceRequirement `yaml:"requests,omitempty"` 366 367 // 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. 368 Limits *ResourceRequirement `yaml:"limits,omitempty"` 369 } 370 371 // ResourceRequirement stores the CPU/Memory requirements for the pod. 372 type ResourceRequirement struct { 373 // CPU the number cores to be used. 374 // For example: `2`, `2.0` or `200m`. 375 CPU string `yaml:"cpu,omitempty"` 376 377 // Memory the amount of memory to allocate to the pod. 378 // For example: `1Gi` or `1000Mi`. 379 Memory string `yaml:"memory,omitempty"` 380 381 // EphemeralStorage the amount of Ephemeral storage to allocate to the pod. 382 // For example: `1Gi` or `1000Mi`. 383 EphemeralStorage string `yaml:"ephemeralStorage,omitempty"` 384 385 // ResourceStorage the amount of resource storage to allocate to the pod. 386 // For example: `1Gi` or `1000Mi`. 387 ResourceStorage string `yaml:"resourceStorage,omitempty"` 388 } 389 390 // TestCase is a list of structure tests to run on images that Skaffold builds. 391 type TestCase struct { 392 // ImageName is the artifact on which to run those tests. 393 // For example: `gcr.io/k8s-skaffold/example`. 394 ImageName string `yaml:"image" yamltags:"required"` 395 396 // StructureTests lists the [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) 397 // to run on that artifact. 398 // For example: `["./test/*"]`. 399 StructureTests []string `yaml:"structureTests,omitempty"` 400 } 401 402 // DeployConfig contains all the configuration needed by the deploy steps. 403 type DeployConfig struct { 404 DeployType `yaml:",inline"` 405 406 // StatusCheckDeadlineSeconds *beta* is the deadline for deployments to stabilize in seconds. 407 StatusCheckDeadlineSeconds int `yaml:"statusCheckDeadlineSeconds,omitempty"` 408 409 // KubeContext is the Kubernetes context that Skaffold should deploy to. 410 // For example: `minikube`. 411 KubeContext string `yaml:"kubeContext,omitempty"` 412 } 413 414 // DeployType contains the specific implementation and parameters needed 415 // for the deploy step. All three deployer types can be used at the same 416 // time for hybrid workflows. 417 type DeployType struct { 418 // HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. 419 HelmDeploy *HelmDeploy `yaml:"helm,omitempty"` 420 421 // KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. 422 // You'll need a `kubectl` CLI version installed that's compatible with your cluster. 423 KubectlDeploy *KubectlDeploy `yaml:"kubectl,omitempty"` 424 425 // KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. 426 KustomizeDeploy *KustomizeDeploy `yaml:"kustomize,omitempty"` 427 } 428 429 // KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. 430 // You'll need a `kubectl` CLI version installed that's compatible with your cluster. 431 type KubectlDeploy struct { 432 // Manifests lists the Kubernetes yaml or json manifests. 433 // Defaults to `["k8s/*.yaml"]`. 434 Manifests []string `yaml:"manifests,omitempty"` 435 436 // RemoteManifests lists Kubernetes manifests in remote clusters. 437 RemoteManifests []string `yaml:"remoteManifests,omitempty"` 438 439 // Flags are additional flags passed to `kubectl`. 440 Flags KubectlFlags `yaml:"flags,omitempty"` 441 } 442 443 // KubectlFlags are additional flags passed on the command 444 // line to kubectl either on every command (Global), on creations (Apply) 445 // or deletions (Delete). 446 type KubectlFlags struct { 447 // Global are additional flags passed on every command. 448 Global []string `yaml:"global,omitempty"` 449 450 // Apply are additional flags passed on creations (`kubectl apply`). 451 Apply []string `yaml:"apply,omitempty"` 452 453 // Delete are additional flags passed on deletions (`kubectl delete`). 454 Delete []string `yaml:"delete,omitempty"` 455 456 // DisableValidation passes the `--validate=false` flag to supported 457 // `kubectl` commands when enabled. 458 DisableValidation bool `yaml:"disableValidation,omitempty"` 459 } 460 461 // HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. 462 type HelmDeploy struct { 463 // Releases is a list of Helm releases. 464 Releases []HelmRelease `yaml:"releases,omitempty" yamltags:"required"` 465 466 // Flags are additional option flags that are passed on the command 467 // line to `helm`. 468 Flags HelmDeployFlags `yaml:"flags,omitempty"` 469 } 470 471 // HelmDeployFlags are additional option flags that are passed on the command 472 // line to `helm`. 473 type HelmDeployFlags struct { 474 // Global are additional flags passed on every command. 475 Global []string `yaml:"global,omitempty"` 476 477 // Install are additional flags passed to (`helm install`). 478 Install []string `yaml:"install,omitempty"` 479 480 // Upgrade are additional flags passed to (`helm upgrade`). 481 Upgrade []string `yaml:"upgrade,omitempty"` 482 } 483 484 // KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. 485 type KustomizeDeploy struct { 486 // KustomizePaths is the path to Kustomization files. 487 // Defaults to `["."]`. 488 KustomizePaths []string `yaml:"paths,omitempty"` 489 490 // Flags are additional flags passed to `kubectl`. 491 Flags KubectlFlags `yaml:"flags,omitempty"` 492 493 // BuildArgs are additional args passed to `kustomize build`. 494 BuildArgs []string `yaml:"buildArgs,omitempty"` 495 } 496 497 // HelmRelease describes a helm release to be deployed. 498 type HelmRelease struct { 499 // Name is the name of the Helm release. 500 Name string `yaml:"name,omitempty" yamltags:"required"` 501 502 // ChartPath is the path to the Helm chart. 503 ChartPath string `yaml:"chartPath,omitempty" yamltags:"required"` 504 505 // ValuesFiles are the paths to the Helm `values` files. 506 ValuesFiles []string `yaml:"valuesFiles,omitempty"` 507 508 // ArtifactOverrides are key value pairs where 509 // key represents the parameter used in `values` file to define a container image and 510 // value corresponds to artifact i.e. `ImageName` defined in `Build.Artifacts` section. 511 ArtifactOverrides map[string]string `yaml:"artifactOverrides,omitempty,omitempty"` 512 513 // Namespace is the Kubernetes namespace. 514 Namespace string `yaml:"namespace,omitempty"` 515 516 // Version is the version of the chart. 517 Version string `yaml:"version,omitempty"` 518 519 // SetValues are key-value pairs. 520 // If present, Skaffold will send `--set` flag to Helm CLI and append all pairs after the flag. 521 SetValues map[string]string `yaml:"setValues,omitempty"` 522 523 // SetValueTemplates are key-value pairs. 524 // If present, Skaffold will try to parse the value part of each key-value pair using 525 // environment variables in the system, then send `--set` flag to Helm CLI and append 526 // all parsed pairs after the flag. 527 SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` 528 529 // SetFiles are key-value pairs. 530 // If present, Skaffold will send `--set-file` flag to Helm CLI and append all pairs after the flag. 531 SetFiles map[string]string `yaml:"setFiles,omitempty"` 532 533 // Wait if `true`, Skaffold will send `--wait` flag to Helm CLI. 534 // Defaults to `false`. 535 Wait bool `yaml:"wait,omitempty"` 536 537 // RecreatePods if `true`, Skaffold will send `--recreate-pods` flag to Helm CLI 538 // when upgrading a new version of a chart in subsequent dev loop deploy. 539 // Defaults to `false`. 540 RecreatePods bool `yaml:"recreatePods,omitempty"` 541 542 // SkipBuildDependencies should build dependencies be skipped. 543 // Ignored when `remote: true`. 544 SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"` 545 546 // UseHelmSecrets instructs skaffold to use secrets plugin on deployment. 547 UseHelmSecrets bool `yaml:"useHelmSecrets,omitempty"` 548 549 // Remote specifies whether the chart path is remote, or exists on the host filesystem. 550 Remote bool `yaml:"remote,omitempty"` 551 552 // UpgradeOnChange specifies whether to upgrade helm chart on code changes. 553 // Default is `true` when helm chart is local (`remote: false`). 554 // Default is `false` if `remote: true`. 555 UpgradeOnChange *bool `yaml:"upgradeOnChange,omitempty"` 556 557 // Overrides are key-value pairs. 558 // If present, Skaffold will build a Helm `values` file that overrides 559 // the original and use it to call Helm CLI (`--f` flag). 560 Overrides util.HelmOverrides `yaml:"overrides,omitempty"` 561 562 // Packaged parameters for packaging helm chart (`helm package`). 563 Packaged *HelmPackaged `yaml:"packaged,omitempty"` 564 565 // ImageStrategy adds image configurations to the Helm `values` file. 566 ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` 567 } 568 569 // HelmPackaged parameters for packaging helm chart (`helm package`). 570 type HelmPackaged struct { 571 // Version sets the `version` on the chart to this semver version. 572 Version string `yaml:"version,omitempty"` 573 574 // AppVersion sets the `appVersion` on the chart to this version. 575 AppVersion string `yaml:"appVersion,omitempty"` 576 } 577 578 // HelmImageStrategy adds image configurations to the Helm `values` file. 579 type HelmImageStrategy struct { 580 HelmImageConfig `yaml:",inline"` 581 } 582 583 // HelmImageConfig describes an image configuration. 584 type HelmImageConfig struct { 585 // HelmFQNConfig is the image configuration uses the syntax `IMAGE-NAME=IMAGE-REPOSITORY:IMAGE-TAG`. 586 HelmFQNConfig *HelmFQNConfig `yaml:"fqn,omitempty" yamltags:"oneOf=helmImageStrategy"` 587 588 // HelmConventionConfig is the image configuration uses the syntax `IMAGE-NAME.repository=IMAGE-REPOSITORY, IMAGE-NAME.tag=IMAGE-TAG`. 589 HelmConventionConfig *HelmConventionConfig `yaml:"helm,omitempty" yamltags:"oneOf=helmImageStrategy"` 590 } 591 592 // HelmFQNConfig is the image config to use the FullyQualifiedImageName as param to set. 593 type HelmFQNConfig struct { 594 // Property defines the image config. 595 Property string `yaml:"property,omitempty"` 596 } 597 598 // HelmConventionConfig is the image config in the syntax of image.repository and image.tag. 599 type HelmConventionConfig struct { 600 // ExplicitRegistry separates `image.registry` to the image config syntax. Useful for some charts e.g. `postgresql`. 601 ExplicitRegistry bool `yaml:"explicitRegistry,omitempty"` 602 } 603 604 // Artifact are the items that need to be built, along with the context in which 605 // they should be built. 606 type Artifact struct { 607 // ImageName is the name of the image to be built. 608 // For example: `gcr.io/k8s-skaffold/example`. 609 ImageName string `yaml:"image,omitempty" yamltags:"required"` 610 611 // Workspace is the directory containing the artifact's sources. 612 // Defaults to `.`. 613 Workspace string `yaml:"context,omitempty"` 614 615 // Sync *beta* lists local files synced to pods instead 616 // of triggering an image build when modified. 617 // If no files are listed, sync all the files and infer the destination. 618 // Defaults to `infer: ["**/*"]`. 619 Sync *Sync `yaml:"sync,omitempty"` 620 621 // ArtifactType describes how to build an artifact. 622 ArtifactType `yaml:",inline"` 623 } 624 625 // Sync *beta* specifies what files to sync into the container. 626 // This is a list of sync rules indicating the intent to sync for source files. 627 // If no files are listed, sync all the files and infer the destination. 628 // Defaults to `infer: ["**/*"]`. 629 type Sync struct { 630 // Manual lists manual sync rules indicating the source and destination. 631 Manual []*SyncRule `yaml:"manual,omitempty" yamltags:"oneOf=sync"` 632 633 // Infer lists file patterns which may be synced into the container 634 // The container destination is inferred by the builder 635 // based on the instructions of a Dockerfile. 636 // Available for docker and kaniko artifacts and custom 637 // artifacts that declare dependencies on a dockerfile. 638 Infer []string `yaml:"infer,omitempty" yamltags:"oneOf=sync"` 639 640 // Auto delegates discovery of sync rules to the build system. 641 // Only available for jib and buildpacks. 642 Auto *Auto `yaml:"auto,omitempty" yamltags:"oneOf=sync"` 643 } 644 645 // SyncRule specifies which local files to sync to remote folders. 646 type SyncRule struct { 647 // Src is a glob pattern to match local paths against. 648 // Directories should be delimited by `/` on all platforms. 649 // For example: `"css/**/*.css"`. 650 Src string `yaml:"src,omitempty" yamltags:"required"` 651 652 // Dest is the destination path in the container where the files should be synced to. 653 // For example: `"app/"` 654 Dest string `yaml:"dest,omitempty" yamltags:"required"` 655 656 // Strip specifies the path prefix to remove from the source path when 657 // transplanting the files into the destination folder. 658 // For example: `"css/"` 659 Strip string `yaml:"strip,omitempty"` 660 } 661 662 // Auto cannot be customized. 663 type Auto struct{} 664 665 // Profile is used to override any `build`, `test` or `deploy` configuration. 666 type Profile struct { 667 // Name is a unique profile name. 668 // For example: `profile-prod`. 669 Name string `yaml:"name,omitempty" yamltags:"required"` 670 671 // Activation criteria by which a profile can be auto-activated. 672 // The profile is auto-activated if any one of the activations are triggered. 673 // An activation is triggered if all of the criteria (env, kubeContext, command) are triggered. 674 Activation []Activation `yaml:"activation,omitempty"` 675 676 // Patches lists patches applied to the configuration. 677 // Patches use the JSON patch notation. 678 Patches []JSONPatch `yaml:"patches,omitempty"` 679 680 // Pipeline contains the definitions to replace the default skaffold pipeline. 681 Pipeline `yaml:",inline"` 682 } 683 684 // JSONPatch patch to be applied by a profile. 685 type JSONPatch struct { 686 // Op is the operation carried by the patch: `add`, `remove`, `replace`, `move`, `copy` or `test`. 687 // Defaults to `replace`. 688 Op string `yaml:"op,omitempty"` 689 690 // Path is the position in the yaml where the operation takes place. 691 // For example, this targets the `dockerfile` of the first artifact built. 692 // For example: `/build/artifacts/0/docker/dockerfile`. 693 Path string `yaml:"path,omitempty" yamltags:"required"` 694 695 // From is the source position in the yaml, used for `copy` or `move` operations. 696 From string `yaml:"from,omitempty"` 697 698 // Value is the value to apply. Can be any portion of yaml. 699 Value *util.YamlpatchNode `yaml:"value,omitempty"` 700 } 701 702 // Activation criteria by which a profile is auto-activated. 703 type Activation struct { 704 // Env is a `key=pattern` pair. The profile is auto-activated if an Environment 705 // Variable `key` matches the pattern. If the pattern starts with `!`, activation 706 // happens if the remaining pattern is _not_ matched. The pattern matches if the 707 // Environment Variable value is exactly `pattern`, or the regex `pattern` is 708 // found in it. An empty `pattern` (e.g. `env: "key="`) always only matches if 709 // the Environment Variable is undefined or empty. 710 // For example: `ENV=production` 711 Env string `yaml:"env,omitempty"` 712 713 // KubeContext is a Kubernetes context for which the profile is auto-activated. 714 // For example: `minikube`. 715 KubeContext string `yaml:"kubeContext,omitempty"` 716 717 // Command is a Skaffold command for which the profile is auto-activated. 718 // For example: `dev`. 719 Command string `yaml:"command,omitempty"` 720 } 721 722 // ArtifactType describes how to build an artifact. 723 type ArtifactType struct { 724 // DockerArtifact *beta* describes an artifact built from a Dockerfile. 725 DockerArtifact *DockerArtifact `yaml:"docker,omitempty" yamltags:"oneOf=artifact"` 726 727 // BazelArtifact *beta* requires bazel CLI to be installed and the sources to 728 // contain [Bazel](https://bazel.build/) configuration files. 729 BazelArtifact *BazelArtifact `yaml:"bazel,omitempty" yamltags:"oneOf=artifact"` 730 731 // JibArtifact builds images using the 732 // [Jib plugins for Maven or Gradle](https://github.com/GoogleContainerTools/jib/). 733 JibArtifact *JibArtifact `yaml:"jib,omitempty" yamltags:"oneOf=artifact"` 734 735 // KanikoArtifact builds images using [kaniko](https://github.com/GoogleContainerTools/kaniko). 736 KanikoArtifact *KanikoArtifact `yaml:"kaniko,omitempty" yamltags:"oneOf=artifact"` 737 738 // BuildpackArtifact builds images using [Cloud Native Buildpacks](https://buildpacks.io/). 739 BuildpackArtifact *BuildpackArtifact `yaml:"buildpacks,omitempty" yamltags:"oneOf=artifact"` 740 741 // CustomArtifact *beta* builds images using a custom build script written by the user. 742 CustomArtifact *CustomArtifact `yaml:"custom,omitempty" yamltags:"oneOf=artifact"` 743 } 744 745 // BuildpackArtifact *alpha* describes an artifact built using [Cloud Native Buildpacks](https://buildpacks.io/). 746 // It can be used to build images out of project's sources without any additional configuration. 747 type BuildpackArtifact struct { 748 // Builder is the builder image used. 749 Builder string `yaml:"builder" yamltags:"required"` 750 751 // RunImage overrides the stack's default run image. 752 RunImage string `yaml:"runImage,omitempty"` 753 754 // Env are environment variables, in the `key=value` form, passed to the build. 755 // Values can use the go template syntax. 756 // For example: `["key1=value1", "key2=value2", "key3={{.ENV_VARIABLE}}"]`. 757 Env []string `yaml:"env,omitempty"` 758 759 // Buildpacks is a list of strings, where each string is a specific buildpack to use with the builder. 760 // 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. 761 // Order matters. 762 Buildpacks []string `yaml:"buildpacks,omitempty"` 763 764 // TrustBuilder indicates that the builder should be trusted. 765 TrustBuilder bool `yaml:"trustBuilder,omitempty"` 766 767 // ProjectDescriptor is the path to the project descriptor file. 768 // Defaults to `project.toml` if it exists. 769 ProjectDescriptor string `yaml:"projectDescriptor,omitempty"` 770 771 // Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. 772 Dependencies *BuildpackDependencies `yaml:"dependencies,omitempty"` 773 } 774 775 // BuildpackDependencies *alpha* is used to specify dependencies for an artifact built by buildpacks. 776 type BuildpackDependencies struct { 777 // 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. 778 Paths []string `yaml:"paths,omitempty" yamltags:"oneOf=dependency"` 779 780 // 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. 781 // Will only work in conjunction with `paths`. 782 Ignore []string `yaml:"ignore,omitempty"` 783 } 784 785 // CustomArtifact *beta* describes an artifact built from a custom build script 786 // written by the user. It can be used to build images with builders that aren't directly integrated with skaffold. 787 type CustomArtifact struct { 788 // BuildCommand is the command executed to build the image. 789 BuildCommand string `yaml:"buildCommand,omitempty"` 790 // Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. 791 Dependencies *CustomDependencies `yaml:"dependencies,omitempty"` 792 } 793 794 // CustomDependencies *beta* is used to specify dependencies for an artifact built by a custom build script. 795 // Either `dockerfile` or `paths` should be specified for file watching to work as expected. 796 type CustomDependencies struct { 797 // Dockerfile should be set if the artifact is built from a Dockerfile, from which skaffold can determine dependencies. 798 Dockerfile *DockerfileDependency `yaml:"dockerfile,omitempty" yamltags:"oneOf=dependency"` 799 800 // Command represents a custom command that skaffold executes to obtain dependencies. The output of this command *must* be a valid JSON array. 801 Command string `yaml:"command,omitempty" yamltags:"oneOf=dependency"` 802 803 // 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. 804 Paths []string `yaml:"paths,omitempty" yamltags:"oneOf=dependency"` 805 806 // 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. 807 // Will only work in conjunction with `paths`. 808 Ignore []string `yaml:"ignore,omitempty"` 809 } 810 811 // 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. 812 type DockerfileDependency struct { 813 // Path locates the Dockerfile relative to workspace. 814 Path string `yaml:"path,omitempty"` 815 816 // BuildArgs are key/value pairs used to resolve values of `ARG` instructions in a Dockerfile. 817 // Values can be constants or environment variables via the go template syntax. 818 // For example: `{"key1": "value1", "key2": "value2", "key3": "'{{.ENV_VARIABLE}}'"}`. 819 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 820 } 821 822 // KanikoArtifact describes an artifact built from a Dockerfile, 823 // with kaniko. 824 type KanikoArtifact struct { 825 // AdditionalFlags are additional flags to be passed to Kaniko command line. 826 // See [Kaniko Additional Flags](https://github.com/GoogleContainerTools/kaniko#additional-flags). 827 // Deprecated - instead the named, unique fields should be used, e.g. `buildArgs`, `cache`, `target`. 828 AdditionalFlags []string `yaml:"flags,omitempty"` 829 830 // DockerfilePath locates the Dockerfile relative to workspace. 831 // Defaults to `Dockerfile`. 832 DockerfilePath string `yaml:"dockerfile,omitempty"` 833 834 // Target is the Dockerfile target name to build. 835 Target string `yaml:"target,omitempty"` 836 837 // BuildArgs are arguments passed to the docker build. 838 // It also accepts environment variables via the go template syntax. 839 // For example: `{"key1": "value1", "key2": "value2", "key3": "'{{.ENV_VARIABLE}}'"}`. 840 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 841 842 // Env are environment variables passed to the kaniko pod. 843 Env []v1.EnvVar `yaml:"env,omitempty"` 844 845 // InitImage is the image used to run init container which mounts kaniko context. 846 InitImage string `yaml:"initImage,omitempty"` 847 848 // Image is the Docker image used by the Kaniko pod. 849 // Defaults to the latest released version of `gcr.io/kaniko-project/executor`. 850 Image string `yaml:"image,omitempty"` 851 852 // Cache configures Kaniko caching. If a cache is specified, Kaniko will 853 // use a remote cache which will speed up builds. 854 Cache *KanikoCache `yaml:"cache,omitempty"` 855 856 // Reproducible is used to strip timestamps out of the built image. 857 Reproducible bool `yaml:"reproducible,omitempty"` 858 859 // SkipTLS skips TLS verification when pulling and pushing the image. 860 SkipTLS bool `yaml:"skipTLS,omitempty"` 861 862 // VolumeMounts are volume mounts passed to kaniko pod. 863 VolumeMounts []v1.VolumeMount `yaml:"volumeMounts,omitempty"` 864 } 865 866 // DockerArtifact describes an artifact built from a Dockerfile, 867 // usually using `docker build`. 868 type DockerArtifact struct { 869 // DockerfilePath locates the Dockerfile relative to workspace. 870 // Defaults to `Dockerfile`. 871 DockerfilePath string `yaml:"dockerfile,omitempty"` 872 873 // Target is the Dockerfile target name to build. 874 Target string `yaml:"target,omitempty"` 875 876 // BuildArgs are arguments passed to the docker build. 877 // For example: `{"key1": "value1", "key2": "value2"}`. 878 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 879 880 // NetworkMode is passed through to docker and overrides the 881 // network configuration of docker builder. If unset, use whatever 882 // is configured in the underlying docker daemon. Valid modes are 883 // `host`: use the host's networking stack. 884 // `bridge`: use the bridged network configuration. 885 // `none`: no networking in the container. 886 NetworkMode string `yaml:"network,omitempty"` 887 888 // CacheFrom lists the Docker images used as cache sources. 889 // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. 890 CacheFrom []string `yaml:"cacheFrom,omitempty"` 891 892 // NoCache used to pass in --no-cache to docker build to prevent caching. 893 NoCache bool `yaml:"noCache,omitempty"` 894 } 895 896 // BazelArtifact describes an artifact built with [Bazel](https://bazel.build/). 897 type BazelArtifact struct { 898 // BuildTarget is the `bazel build` target to run. 899 // For example: `//:skaffold_example.tar`. 900 BuildTarget string `yaml:"target,omitempty" yamltags:"required"` 901 902 // BuildArgs are additional args to pass to `bazel build`. 903 // For example: `["-flag", "--otherflag"]`. 904 BuildArgs []string `yaml:"args,omitempty"` 905 } 906 907 // JibArtifact builds images using the 908 // [Jib plugins for Maven and Gradle](https://github.com/GoogleContainerTools/jib/). 909 type JibArtifact struct { 910 // Project selects which sub-project to build for multi-module builds. 911 Project string `yaml:"project,omitempty"` 912 913 // Flags are additional build flags passed to the builder. 914 // For example: `["--no-build-cache"]`. 915 Flags []string `yaml:"args,omitempty"` 916 917 // Type the Jib builder type; normally determined automatically. Valid types are 918 // `maven`: for Maven. 919 // `gradle`: for Gradle. 920 Type string `yaml:"type,omitempty"` 921 }