Skip to content

Commit

Permalink
use in-cluster config
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbehery committed Jul 12, 2024
1 parent f3af2ab commit b966a02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions bindata/etcd/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ ${COMPUTED_ENV_VARS}
name: backup-dir
- mountPath: /etc/kubernetes
name: config-dir
- mountPath: /etc/kubernetes/static-pod-certs
name: cert-dir
hostNetwork: true
priorityClassName: system-node-critical
tolerations:
Expand Down
17 changes: 8 additions & 9 deletions pkg/cmd/backuprestore/backupnoconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"context"
"fmt"
"io"
"k8s.io/client-go/rest"
"slices"

backupv1alpha1 "github.com/openshift/api/config/v1alpha1"
backupv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1alpha1"
prunebackups "github.com/openshift/cluster-etcd-operator/pkg/cmd/prune-backups"

v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"

"github.com/adhocore/gronx/pkg/tasker"
Expand All @@ -20,11 +20,10 @@ import (
)

type backupNoConfig struct {
kubeConfig string
schedule string
timeZone string
retention backupv1alpha1.RetentionPolicy
scheduler *tasker.Tasker
schedule string
timeZone string
retention backupv1alpha1.RetentionPolicy
scheduler *tasker.Tasker
backupOptions
}

Expand Down Expand Up @@ -93,14 +92,14 @@ func (b *backupNoConfig) Run() error {
}

func (b *backupNoConfig) getBackupClient() (backupv1client.BackupsGetter, error) {
kubeConfig, err := clientcmd.BuildConfigFromFlags("", b.kubeConfig)
config, err := rest.InClusterConfig()
if err != nil {
bErr := fmt.Errorf("error loading kubeconfig: %v", err)
bErr := fmt.Errorf("error loading in-cluster kube client config: %v", err)
klog.Error(bErr)
return nil, bErr
}

backupsClient, err := backupv1client.NewForConfig(kubeConfig)
backupsClient, err := backupv1client.NewForConfig(config)
if err != nil {
bErr := fmt.Errorf("error creating etcd backups client: %v", err)
klog.Error(bErr)
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/etcd_assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b966a02

Please sign in to comment.