-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(k8s): dynamic account config (#3824)
* feat(k8s): dynamic account config implement credential synchronization for kubernetes accounts. defines `CredentialsInitializerSynchronizable` on the `KubernetesV*ProviderConfig` classes. Each of these classes is responsible for handling accounts for each provider version. * feat(k8s): detemine if account has changed * refactor(k8s): rename provider config classes renames provider config classes to synchronizable since there is no longer an `@Configuration` annotation. * refactor(k8s): add file hash signature adds a `kubeconfigFileHash` property which enables us to determine if the file contents of the kubeconfig file changed even if the path hasn't changed. this kind of change warrants an account refresh becuase the credentials used by the account may have possibly changed. * refactor(k8s): defer to computedOmitKinds previously, we were modifying omitKinds when an account was initialized. this caused calls to `equals` to fail because they didn't match configured omitKinds. this change defers to `omitKindsComputed` so that checking new and existing credentials is accurate according to how the account it configured. this allows us to only initialize modified or new accounts rather than every credential.
- Loading branch information
1 parent
8e5780e
commit 8b941c7
Showing
16 changed files
with
753 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...in/groovy/com/netflix/spinnaker/clouddriver/kubernetes/security/KubeconfigFileHasher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2019 Armory | ||
* | ||
* 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 com.netflix.spinnaker.clouddriver.kubernetes.security; | ||
|
||
import com.google.common.hash.Hashing; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class KubeconfigFileHasher { | ||
|
||
public static String hashKubeconfigFile(String filepath) { | ||
try { | ||
byte[] contents = Files.readAllBytes(Paths.get(filepath)); | ||
return Hashing.sha256().hashBytes(contents).toString(); | ||
} catch (Exception e) { | ||
log.warn("failed to hash kubeconfig file at {}: {}", filepath, e); | ||
return ""; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 0 additions & 75 deletions
75
...naker/clouddriver/kubernetes/security/KubernetesNamedAccountCredentialsInitializer.groovy
This file was deleted.
Oops, something went wrong.
88 changes: 0 additions & 88 deletions
88
...om/netflix/spinnaker/clouddriver/kubernetes/v1/provider/KubernetesV1ProviderConfig.groovy
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.