Skip to content

Instantly share code, notes, and snippets.

@mrIncompetent
Last active January 3, 2018 17:39
Show Gist options
  • Save mrIncompetent/9f89910efda6d945d0e17cc657f42700 to your computer and use it in GitHub Desktop.
Save mrIncompetent/9f89910efda6d945d0e17cc657f42700 to your computer and use it in GitHub Desktop.
MachineSet type based on ReplicaSet
/*
Copyright 2017 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 v1alpha1 contains types to represent Kubernetes cluster and
// machine configuration.
package v1alpha1 // import "k8s.io/kube-deploy/cluster-api/api/cluster/v1alpha1"
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type MachineSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec MachineSetSpec `json:"spec"`
Status MachineSetStatus `json:"status,omitempty"`
}
// MachineSetSpec is the specification of a MachineSet.
type MachineSetSpec struct {
// Replicas is the number of desired replicas.
// This is a pointer to distinguish between explicit zero and unspecified.
// Defaults to 1.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
// Minimum number of seconds for which a newly created machine should be ready.
// Defaults to 0 (machine will be considered available as soon as it has a reference to a node and the node is considered ready)
// +optional
MinReadySeconds int32 `json:"minReadySeconds,omitempty"`
// Selector is a label query over machines that should match the replica count.
// Label keys and values that must match in order to be controlled by this MachineSet.
// It must match the machine template's labels.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
Selector *metav1.LabelSelector `json:"selector"`
// Template is the object that describes the machine that will be created if
// insufficient replicas are detected.
// +optional
Template MachineTemplateSpec `json:"template,omitempty"`
}
// MachineTemplateSpec describes the data a machine should have when created from a template
type MachineTemplateSpec struct {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the machine.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
// +optional
Spec MachineSpec `json:"spec,omitempty"`
}
// MachineSetStatus represents the current status of a MachineSet.
type MachineSetStatus struct {
// Replicas is the most recently observed number of replicas.
Replicas int32 `json:"replicas"`
// The number of machines that have labels matching the labels of the machine template of the MachineSet.
// +optional
FullyLabeledReplicas int32 `json:"fullyLabeledReplicas,omitempty"`
// The number of ready replicas for this MachineSet.
// +optional
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
// The number of available replicas (ready for at least minReadySeconds) for this MachineSet.
// +optional
AvailableReplicas int32 `json:"availableReplicas,omitempty"`
// ObservedGeneration reflects the generation of the most recently observed MachineSet.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment