Remove UniqueLabelKey from deployment spec

This commit is contained in:
Janet Kuo 2016-02-05 14:45:05 -08:00
parent 8f3eb93626
commit 7e9fb97b7d
20 changed files with 12444 additions and 12636 deletions

File diff suppressed because it is too large Load Diff

View File

@ -252,16 +252,6 @@ type DeploymentSpec struct {
// This is a pointer to distinguish between explicit zero and not specified.
RevisionHistoryLimit *int `json:"revisionHistoryLimit,omitempty"`
// Key of the selector that is added to existing RCs (and label key that is
// added to its pods) to prevent the existing RCs to select new pods (and old
// pods being selected by new RC).
// Users can set this to an empty string to indicate that the system should
// not add any selector and label. If unspecified, system uses
// DefaultDeploymentUniqueLabelKey("deployment.kubernetes.io/podTemplateHash").
// Value of this key is hash of DeploymentSpec.PodTemplateSpec.
// No label is added if this is set to empty string.
UniqueLabelKey string `json:"uniqueLabelKey,omitempty"`
// Indicates that the deployment is paused and will not be processed by the
// deployment controller.
Paused bool `json:"paused,omitempty"`
@ -288,9 +278,8 @@ type RollbackConfig struct {
const (
// DefaultDeploymentUniqueLabelKey is the default key of the selector that is added
// to existing RCs (and label key that is added to its pods) to prevent the existing RCs
// to select new pods (and old pods being select by new RC). See DeploymentSpec's UniqueLabelKey
// field for more information.
DefaultDeploymentUniqueLabelKey string = "deployment.kubernetes.io/podTemplateHash"
// to select new pods (and old pods being select by new RC).
DefaultDeploymentUniqueLabelKey string = "pod-template-hash"
)
type DeploymentStrategy struct {

View File

@ -121,8 +121,6 @@ func Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.
out.RevisionHistoryLimit = new(int32)
*out.RevisionHistoryLimit = int32(*in.RevisionHistoryLimit)
}
out.UniqueLabelKey = new(string)
*out.UniqueLabelKey = in.UniqueLabelKey
out.MinReadySeconds = int32(in.MinReadySeconds)
out.Paused = in.Paused
if in.RollbackTo != nil {
@ -159,9 +157,6 @@ func Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentS
out.RevisionHistoryLimit = new(int)
*out.RevisionHistoryLimit = int(*in.RevisionHistoryLimit)
}
if in.UniqueLabelKey != nil {
out.UniqueLabelKey = *in.UniqueLabelKey
}
out.MinReadySeconds = int(in.MinReadySeconds)
out.Paused = in.Paused
if in.RollbackTo != nil {

View File

@ -2830,9 +2830,6 @@ func autoConvert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensi
} else {
out.RevisionHistoryLimit = nil
}
if err := api.Convert_string_To_string_ref(&in.UniqueLabelKey, &out.UniqueLabelKey, s); err != nil {
return err
}
out.Paused = in.Paused
// unable to generate simple pointer conversion for extensions.RollbackConfig -> v1beta1.RollbackConfig
if in.RollbackTo != nil {
@ -4148,9 +4145,6 @@ func autoConvert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *Deploym
} else {
out.RevisionHistoryLimit = nil
}
if err := api.Convert_string_ref_To_string(&in.UniqueLabelKey, &out.UniqueLabelKey, s); err != nil {
return err
}
out.Paused = in.Paused
// unable to generate simple pointer conversion for v1beta1.RollbackConfig -> extensions.RollbackConfig
if in.RollbackTo != nil {

View File

@ -1190,12 +1190,6 @@ func deepCopy_v1beta1_DeploymentSpec(in DeploymentSpec, out *DeploymentSpec, c *
} else {
out.RevisionHistoryLimit = nil
}
if in.UniqueLabelKey != nil {
out.UniqueLabelKey = new(string)
*out.UniqueLabelKey = *in.UniqueLabelKey
} else {
out.UniqueLabelKey = nil
}
out.Paused = in.Paused
if in.RollbackTo != nil {
out.RollbackTo = new(RollbackConfig)

View File

@ -100,10 +100,6 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
strategy.RollingUpdate.MaxSurge = &maxSurge
}
}
if obj.Spec.UniqueLabelKey == nil {
obj.Spec.UniqueLabelKey = new(string)
*obj.Spec.UniqueLabelKey = DefaultDeploymentUniqueLabelKey
}
},
func(obj *Job) {
labels := obj.Spec.Template.Labels

View File

@ -198,7 +198,6 @@ func TestSetDefaultDaemonSet(t *testing.T) {
func TestSetDefaultDeployment(t *testing.T) {
defaultIntOrString := intstr.FromInt(1)
differentIntOrString := intstr.FromInt(5)
deploymentLabelKey := DefaultDeploymentUniqueLabelKey
period := int64(v1.DefaultTerminationGracePeriodSeconds)
defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{
@ -224,8 +223,7 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
Template: defaultTemplate,
UniqueLabelKey: newString(deploymentLabelKey),
Template: defaultTemplate,
},
},
},
@ -250,8 +248,7 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
Template: defaultTemplate,
UniqueLabelKey: newString(deploymentLabelKey),
Template: defaultTemplate,
},
},
},
@ -270,8 +267,7 @@ func TestSetDefaultDeployment(t *testing.T) {
Strategy: DeploymentStrategy{
Type: RecreateDeploymentStrategyType,
},
Template: defaultTemplate,
UniqueLabelKey: newString(deploymentLabelKey),
Template: defaultTemplate,
},
},
},
@ -282,7 +278,6 @@ func TestSetDefaultDeployment(t *testing.T) {
Strategy: DeploymentStrategy{
Type: RecreateDeploymentStrategyType,
},
UniqueLabelKey: newString("customDeploymentKey"),
},
},
expected: &Deployment{
@ -291,8 +286,7 @@ func TestSetDefaultDeployment(t *testing.T) {
Strategy: DeploymentStrategy{
Type: RecreateDeploymentStrategyType,
},
Template: defaultTemplate,
UniqueLabelKey: newString("customDeploymentKey"),
Template: defaultTemplate,
},
},
},

File diff suppressed because it is too large Load Diff

View File

@ -237,16 +237,6 @@ type DeploymentSpec struct {
// This is a pointer to distinguish between explicit zero and not specified.
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty"`
// Key of the selector that is added to existing RCs (and label key that is
// added to its pods) to prevent the existing RCs to select new pods (and old
// pods being selected by new RC).
// Users can set this to an empty string to indicate that the system should
// not add any selector and label. If unspecified, system uses
// DefaultDeploymentUniqueLabelKey("deployment.kubernetes.io/podTemplateHash").
// Value of this key is hash of DeploymentSpec.PodTemplateSpec.
// No label is added if this is set to empty string.
UniqueLabelKey *string `json:"uniqueLabelKey,omitempty"`
// Indicates that the deployment is paused and will not be processed by the
// deployment controller.
Paused bool `json:"paused,omitempty"`
@ -273,9 +263,8 @@ type RollbackConfig struct {
const (
// DefaultDeploymentUniqueLabelKey is the default key of the selector that is added
// to existing RCs (and label key that is added to its pods) to prevent the existing RCs
// to select new pods (and old pods being select by new RC). See DeploymentSpec's UniqueLabelKey
// field for more information.
DefaultDeploymentUniqueLabelKey string = "deployment.kubernetes.io/podTemplateHash"
// to select new pods (and old pods being select by new RC).
DefaultDeploymentUniqueLabelKey string = "pod-template-hash"
)
// DeploymentStrategy describes how to replace existing pods with new ones.

View File

@ -186,7 +186,6 @@ var map_DeploymentSpec = map[string]string{
"strategy": "The deployment strategy to use to replace existing pods with new ones.",
"minReadySeconds": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
"revisionHistoryLimit": "The number of old ReplicationControllers to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified.",
"uniqueLabelKey": "Key of the selector that is added to existing RCs (and label key that is added to its pods) to prevent the existing RCs to select new pods (and old pods being selected by new RC). Users can set this to an empty string to indicate that the system should not add any selector and label. If unspecified, system uses DefaultDeploymentUniqueLabelKey(\"deployment.kubernetes.io/podTemplateHash\"). Value of this key is hash of DeploymentSpec.PodTemplateSpec. No label is added if this is set to empty string.",
"paused": "Indicates that the deployment is paused and will not be processed by the deployment controller.",
"rollbackTo": "The config this deployment is rolling back to. Will be cleared after rollback is done.",
}

View File

@ -328,10 +328,6 @@ func ValidateDeploymentSpec(spec *extensions.DeploymentSpec, fldPath *field.Path
// zero is a valid RevisionHistoryLimit
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*spec.RevisionHistoryLimit), fldPath.Child("revisionHistoryLimit"))...)
}
// empty string is a valid UniqueLabelKey
if len(spec.UniqueLabelKey) > 0 {
allErrs = append(allErrs, apivalidation.ValidateLabelName(spec.UniqueLabelKey, fldPath.Child("uniqueLabel"))...)
}
if spec.RollbackTo != nil {
allErrs = append(allErrs, ValidateRollback(spec.RollbackTo, fldPath.Child("rollback"))...)
}

View File

@ -872,7 +872,6 @@ func validDeployment() *extensions.Deployment {
},
},
},
UniqueLabelKey: "my-label",
RollbackTo: &extensions.RollbackConfig{
Revision: 1,
},
@ -908,11 +907,6 @@ func TestValidateDeployment(t *testing.T) {
invalidRestartPolicyDeployment.Spec.Template.Spec.RestartPolicy = api.RestartPolicyNever
errorCases["Unsupported value: \"Never\""] = invalidRestartPolicyDeployment
// invalid unique label key.
invalidUniqueLabelDeployment := validDeployment()
invalidUniqueLabelDeployment.Spec.UniqueLabelKey = "abc/def/ghi"
errorCases["spec.uniqueLabel: Invalid value"] = invalidUniqueLabelDeployment
// rollingUpdate should be nil for recreate.
invalidRecreateDeployment := validDeployment()
invalidRecreateDeployment.Spec.Strategy = extensions.DeploymentStrategy{

View File

@ -696,7 +696,7 @@ func (dc *DeploymentController) getNewRC(deployment extensions.Deployment, maxOl
podTemplateSpecHash := podutil.GetPodTemplateSpecHash(deployment.Spec.Template)
newRCTemplate := deploymentutil.GetNewRCTemplate(deployment)
// Add podTemplateHash label to selector.
newRCSelector := labelsutil.CloneAndAddLabel(deployment.Spec.Selector, deployment.Spec.UniqueLabelKey, podTemplateSpecHash)
newRCSelector := labelsutil.CloneAndAddLabel(deployment.Spec.Selector, extensions.DefaultDeploymentUniqueLabelKey, podTemplateSpecHash)
// Set RC expectations (1 rc should be created)
dKey, err = controller.KeyFunc(&deployment)

View File

@ -110,7 +110,6 @@ func (DeploymentV1Beta1) Generate(genericParams map[string]interface{}) (runtime
},
Spec: *podSpec,
},
UniqueLabelKey: extensions.DefaultDeploymentUniqueLabelKey,
},
}
return &deployment, nil

View File

@ -655,9 +655,8 @@ func TestGenerateDeployment(t *testing.T) {
Labels: map[string]string{"foo": "bar", "baz": "blah"},
},
Spec: extensions.DeploymentSpec{
Replicas: 3,
Selector: map[string]string{"foo": "bar", "baz": "blah"},
UniqueLabelKey: extensions.DefaultDeploymentUniqueLabelKey,
Replicas: 3,
Selector: map[string]string{"foo": "bar", "baz": "blah"},
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{"foo": "bar", "baz": "blah"},

View File

@ -67,8 +67,7 @@ func validNewDeployment() *extensions.Deployment {
DNSPolicy: api.DNSClusterFirst,
},
},
UniqueLabelKey: "my-label",
Replicas: 7,
Replicas: 7,
},
Status: extensions.DeploymentStatus{
Replicas: 5,

View File

@ -138,7 +138,7 @@ func GetNewRCTemplate(deployment extensions.Deployment) api.PodTemplateSpec {
}
newRCTemplate.ObjectMeta.Labels = labelsutil.CloneAndAddLabel(
deployment.Spec.Template.ObjectMeta.Labels,
deployment.Spec.UniqueLabelKey,
extensions.DefaultDeploymentUniqueLabelKey,
podutil.GetPodTemplateSpecHash(newRCTemplate))
return newRCTemplate
}
@ -149,7 +149,7 @@ func SetFromRCTemplate(deployment *extensions.Deployment, template api.PodTempla
deployment.Spec.Template.Spec = template.Spec
deployment.Spec.Template.ObjectMeta.Labels = labelsutil.CloneAndRemoveLabel(
deployment.Spec.Template.ObjectMeta.Labels,
deployment.Spec.UniqueLabelKey)
extensions.DefaultDeploymentUniqueLabelKey)
return deployment
}

View File

@ -159,9 +159,8 @@ func generateDeployment(image string) extensions.Deployment {
Name: image,
},
Spec: extensions.DeploymentSpec{
Replicas: 1,
Selector: podLabels,
UniqueLabelKey: "deployment.kubernetes.io/podTemplateHash",
Replicas: 1,
Selector: podLabels,
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: podLabels,

View File

@ -101,7 +101,6 @@ func newDeployment(deploymentName string, replicas int, podLabels map[string]str
Type: strategyType,
},
RevisionHistoryLimit: revisionHistoryLimit,
UniqueLabelKey: extensions.DefaultDeploymentUniqueLabelKey,
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: podLabels,

View File

@ -1511,7 +1511,6 @@ func (config *DeploymentConfig) create() error {
Selector: map[string]string{
"name": config.Name,
},
UniqueLabelKey: extensions.DefaultDeploymentUniqueLabelKey,
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{"name": config.Name},