Skip to content

Commit

Permalink
Build images from tar archives
Browse files Browse the repository at this point in the history
This patch introduces TarBits, an implementation of Bits for building
the node image from Kubernetes tar image archives.

The -type is "tar" and -kube-root may be set to one of three values:

  1. A local filesystem path containing the files listed above in a flat
     structure. To prevent an existing local

  2. An HTTP address that contains the files listed above in a structure
     that adheres to the layout of the public GCS buckets kubernetes-release
     and kubernetes-release-dev. For example, if tarRoot is set to
     https://k8s.ci/v1.13 then the following URIs should be valid:

       * https://k8s.ci/v1.13/kubernetes.tar.gz
       * https://k8s.ci/v1.13/bin/GOOS/GOARCH/kube-apiserver.tar
       * https://k8s.ci/v1.13/bin/GOOS/GOARCH/kube-controller-manager.tar
       * https://k8s.ci/v1.13/bin/GOOS/GOARCH/kube-scheduler.tar
       * https://k8s.ci/v1.13/bin/GOOS/GOARCH/kube-proxy.tar
       * https://k8s.ci/v1.13/bin/GOOS/GOARCH/kubeadm
       * https://k8s.ci/v1.13/bin/GOOS/GOARCH/kubectl
       * https://k8s.ci/v1.13/bin/GOOS/GOARCH/kubelet

     The files are downloaded to "$HOME/.kind/tarbits/VERSION" where
     VERSION is the value of the "version" file extracted from the
     kubernetes tarball.

  3. A valid semantic version for a released version of Kubernetes or
     begins with "ci/" or "release/". If the string matches any of these
     then the value is presumed to be a CI or release build hosted on one
     of the public GCS buckets.

     This option also supports values ended with ".txt", ex. "ci/latest.txt".
     In fact, all values beginning with "ci/" or "release/" are first checked
     to see if there's a matching txt file for that value. For example,
     if "ci/latest" is provided then before assuming that is a directory,
     "ci/latest.txt" is queried.

In order to prevent the second two options from conflicting with the first,
a local file path, using the prefix "file://" explicitly indicates the given
tarRoot is a local file path.

The given tarRoot may also take the format tarRoot::localPath where the
tarRoot is separated from the local path where the remote files will be
downloaded.

If no explicit local path is provided then remote files are downloaded to
"$HOME/.kind/tarbits/VERSION" where VERSION is the value extracted from
the "version" file in the "kubernetes.tar.gz" tarball.

If a file is already present on disk with the same size as the remote
equivalent, the file will not be downloaded again.
  • Loading branch information
akutz committed Mar 21, 2019
1 parent ae2d62c commit b1fdf35
Show file tree
Hide file tree
Showing 3 changed files with 470 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/kind/build/nodeimage/nodeimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewCommand() *cobra.Command {
}
cmd.Flags().StringVar(
&flags.BuildType, "type",
"docker", "build type, one of [bazel, docker, apt]",
"docker", "build type, one of [bazel, docker, apt, tar]",
)
cmd.Flags().StringVar(
&flags.Image, "image",
Expand Down
44 changes: 44 additions & 0 deletions pkg/build/kube/files.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package kube

const kubeletService = `[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=http://kubernetes.io/docs/
[Service]
ExecStart=/usr/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10
[Install]
WantedBy=multi-user.target
`

const tenKubeadmConf = `# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/default/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
`
Loading

0 comments on commit b1fdf35

Please sign in to comment.