Skip to content

Commit

Permalink
Update for static pod revision pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi committed Jan 24, 2019
1 parent 2afe40c commit d18046b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions cmd/cluster-kube-controller-manager-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/openshift/cluster-kube-controller-manager-operator/pkg/cmd/operator"
"github.com/openshift/cluster-kube-controller-manager-operator/pkg/cmd/render"
"github.com/openshift/library-go/pkg/operator/staticpod/installerpod"
"github.com/openshift/library-go/pkg/operator/staticpod/prune"
)

func main() {
Expand Down Expand Up @@ -47,6 +48,7 @@ func NewSSCSCommand() *cobra.Command {
cmd.AddCommand(operator.NewOperator())
cmd.AddCommand(render.NewRenderCommand(os.Stderr))
cmd.AddCommand(installerpod.NewInstaller())
cmd.AddCommand(prune.NewPrune())

return cmd
}
2 changes: 1 addition & 1 deletion pkg/apis/kubecontrollermanager/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type KubeControllerManagerOperatorConfig struct {
}

type KubeControllerManagerOperatorConfigSpec struct {
operatorsv1.OperatorSpec `json:",inline"`
operatorsv1.StaticPodOperatorSpec `json:",inline"`

// forceRedeploymentReason can be used to force the redeployment of the kube-controller-manager by providing a unique string.
// This provides a mechanism to kick a previously failed deployment and provide a reason why you think it will work
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/operatorclient/operatorclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ func (c *OperatorClient) Informer() cache.SharedIndexInformer {
return c.Informers.Kubecontrollermanager().V1alpha1().KubeControllerManagerOperatorConfigs().Informer()
}

func (c *OperatorClient) GetStaticPodOperatorState() (*operatorv1.OperatorSpec, *operatorv1.StaticPodOperatorStatus, string, error) {
func (c *OperatorClient) GetStaticPodOperatorState() (*operatorv1.StaticPodOperatorSpec, *operatorv1.StaticPodOperatorStatus, string, error) {
instance, err := c.Informers.Kubecontrollermanager().V1alpha1().KubeControllerManagerOperatorConfigs().Lister().Get("cluster")
if err != nil {
return nil, nil, "", err
}

return &instance.Spec.OperatorSpec, &instance.Status.StaticPodOperatorStatus, instance.ResourceVersion, nil
return &instance.Spec.StaticPodOperatorSpec, &instance.Status.StaticPodOperatorStatus, instance.ResourceVersion, nil
}

func (c *OperatorClient) UpdateStaticPodOperatorStatus(resourceVersion string, status *operatorv1.StaticPodOperatorStatus) (*operatorv1.StaticPodOperatorStatus, error) {
Expand Down
22 changes: 13 additions & 9 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/openshift/cluster-kube-controller-manager-operator/pkg/operator/resourcesynccontroller"
"github.com/openshift/cluster-kube-controller-manager-operator/pkg/operator/targetconfigcontroller"
"github.com/openshift/cluster-kube-controller-manager-operator/pkg/operator/v311_00_assets"
"github.com/openshift/library-go/pkg/operator/staticpod/controller/revision"
)

func RunOperator(ctx *controllercmd.ControllerContext) error {
Expand Down Expand Up @@ -95,12 +96,15 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {
staticPodControllers := staticpod.NewControllers(
operatorclient.TargetNamespace,
"openshift-kube-controller-manager",
"kube-controller-manager-pod",
[]string{"cluster-kube-controller-manager-operator", "installer"},
[]string{"cluster-kube-controller-manager-operator", "prune"},
deploymentConfigMaps,
deploymentSecrets,
operatorClient,
v1helpers.CachedConfigMapGetter(kubeClient, kubeInformersForNamespaces),
v1helpers.CachedSecretGetter(kubeClient, kubeInformersForNamespaces),
kubeClient.CoreV1(),
kubeClient,
dynamicClient,
kubeInformersForNamespaces.InformersFor(operatorclient.TargetNamespace),
Expand Down Expand Up @@ -138,16 +142,16 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {

// deploymentConfigMaps is a list of configmaps that are directly copied for the current values. A different actor/controller modifies these.
// the first element should be the configmap that contains the static pod manifest
var deploymentConfigMaps = []string{
"kube-controller-manager-pod",
"config",
"serviceaccount-ca",
var deploymentConfigMaps = []revision.RevisionResource{
{Name: "kube-controller-manager-pod"},
{Name: "config"},
{Name: "serviceaccount-ca"},
}

// deploymentSecrets is a list of secrets that are directly copied for the current values. A different actor/controller modifies these.
var deploymentSecrets = []string{
"cluster-signing-ca",
"controller-manager-kubeconfig",
"service-account-private-key",
"serving-cert",
var deploymentSecrets = []revision.RevisionResource{
{Name: "cluster-signing-ca"},
{Name: "controller-manager-kubeconfig"},
{Name: "service-account-private-key"},
{Name: "serving-cert"},
}

0 comments on commit d18046b

Please sign in to comment.