mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
Add the ability to turn off image pulling.
This commit is contained in:
@@ -17,6 +17,8 @@ limitations under the License.
|
||||
package api
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/fsouza/go-dockerclient"
|
||||
)
|
||||
@@ -173,6 +175,38 @@ type LivenessProbe struct {
|
||||
InitialDelaySeconds int64 `yaml:"initialDelaySeconds,omitempty" json:"initialDelaySeconds,omitempty"`
|
||||
}
|
||||
|
||||
// PullPolicy describes a policy for if/when to pull a container image
|
||||
type PullPolicy string
|
||||
|
||||
const (
|
||||
// Always attempt to pull the latest image. Container will fail If the pull fails.
|
||||
PullAlways PullPolicy = "PullAlways"
|
||||
// Never pull an image, only use a local image. Container will fail if the image isn't present
|
||||
PullNever PullPolicy = "PullNever"
|
||||
// Pull if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.
|
||||
PullIfNotPresent PullPolicy = "PullIfNotPresent"
|
||||
)
|
||||
|
||||
func IsPullAlways(p PullPolicy) bool {
|
||||
// Default to pull always
|
||||
if len(p) == 0 {
|
||||
return true
|
||||
}
|
||||
return pullPoliciesEqual(p, PullAlways)
|
||||
}
|
||||
|
||||
func IsPullNever(p PullPolicy) bool {
|
||||
return pullPoliciesEqual(p, PullNever)
|
||||
}
|
||||
|
||||
func IsPullIfNotPresent(p PullPolicy) bool {
|
||||
return pullPoliciesEqual(p, PullIfNotPresent)
|
||||
}
|
||||
|
||||
func pullPoliciesEqual(p1, p2 PullPolicy) bool {
|
||||
return strings.ToLower(string(p1)) == strings.ToLower(string(p2))
|
||||
}
|
||||
|
||||
// Container represents a single container that is expected to be run on the host.
|
||||
type Container struct {
|
||||
// Required: This must be a DNS_LABEL. Each container in a pod must
|
||||
@@ -195,6 +229,8 @@ type Container struct {
|
||||
Lifecycle *Lifecycle `yaml:"lifecycle,omitempty" json:"lifecycle,omitempty"`
|
||||
// Optional: Default to false.
|
||||
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
||||
// Optional: Policy for pulling images for this container
|
||||
ImagePullPolicy PullPolicy `json:"imagePullPolicy" yaml:"imagePullPolicy"`
|
||||
}
|
||||
|
||||
// Handler defines a specific action that should be taken
|
||||
|
||||
Reference in New Issue
Block a user