Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh all pull image secrets every hour #110

Merged
merged 6 commits into from
Feb 20, 2024

Conversation

spowelljr
Copy link
Member

@spowelljr spowelljr commented Jan 19, 2024

Fixes #105

Running a ticker that runs every hour that deletes the image pull secret in all namespaces and recreates them

server.go Show resolved Hide resolved
@spowelljr spowelljr changed the title Refresh all pull image secrets every hour Refresh all pull image secrets every six hours Jan 23, 2024
@spowelljr spowelljr changed the title Refresh all pull image secrets every six hours Refresh all pull image secrets hour Jan 30, 2024
}

// refreshAllPullSecrets deletes and recreates image registry pull secrets for all namespaces
func refreshAllPullSecrets() error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets generate tokens for 12 hours in first place so dont have to refresh it that often

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried but when I try to change the expiry it still gives the same value

package main

import (
        "context"
        "fmt"
        "log"
        "time"

        "golang.org/x/oauth2"
        "golang.org/x/oauth2/google"
)

func main() {
        creds, err := google.FindDefaultCredentials(context.Background())
        if err != nil {
                log.Fatal(err)
        }
        token, err := creds.TokenSource.Token()
        if err != nil {
                log.Fatal(err)
        }
        fmt.Println(token.Expiry)
        dur, err := time.ParseDuration("30s")
        if err != nil {
                log.Fatal(err)
        }
        ts := oauth2.ReuseTokenSourceWithExpiry(token, creds.TokenSource, dur)
        token, err = ts.Token()
        if err != nil {
                log.Fatal(err)
        }
        fmt.Println(token.Expiry)
} 

@spowelljr spowelljr changed the title Refresh all pull image secrets hour Refresh all pull image secrets every hour Feb 20, 2024
@medyagh medyagh merged commit d8d3ac9 into GoogleContainerTools:main Feb 20, 2024
2 checks passed
@spowelljr spowelljr deleted the refreshPullSecret branch February 20, 2024 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gcp-auth (image pull) secret not refreshed?
3 participants