-
Notifications
You must be signed in to change notification settings - Fork 62
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
Create default passwords when dev mode is set. #441 #442
base: main
Are you sure you want to change the base?
Changes from 20 commits
3a974cb
a9c683f
6d85851
8dedc1e
704bc78
ee9dc06
d392287
0c62564
1e1b980
3d884da
f31a08e
c355ba1
8158551
78e1e40
7d81b27
a8c3016
80a785b
3c3511d
bf8e2cc
f76db50
86b26a2
35fc902
e4c78de
700a841
5830b22
d1ed81a
f0754f7
3ab4fd3
c8ac946
e02a5d2
f67a91c
dbf56c2
d029f62
570ca30
2fe31a3
e4831cd
1cd1773
70e3d37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: argocd-rbac-cm | ||
app.kubernetes.io/part-of: argocd | ||
name: argocd-rbac-cm | ||
namespace: argocd | ||
data: | ||
policy.csv: | | ||
p, role:developer, applications, *, *, allow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of having a separate account that has a very similar permissions as admin? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an account for the developers and it only allows to handle applications There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you tell me if this is inline with what you are thinking?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Option 2 => Use a known password for the developer and admin account if the dev password flag is set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok that sounds good to me. Looks like Gitea static password isn't working for some reason? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For gitea when using dev-mode, we should still use as user: giteaAdmin and password = developer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you are adding a user called developer to argocd, we may as well add the developer user in Gitea. |
||
g, developer, role:developer |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ var ( | |
|
||
type Build struct { | ||
name string | ||
devMode bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed: 35fc902 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still set as |
||
cfg v1alpha1.BuildCustomizationSpec | ||
kindConfigPath string | ||
kubeConfigPath string | ||
|
@@ -278,5 +279,6 @@ func isBuildCustomizationSpecEqual(s1, s2 v1alpha1.BuildCustomizationSpec) bool | |
s1.IngressHost == s2.IngressHost && | ||
s1.Port == s2.Port && | ||
s1.UsePathRouting == s2.UsePathRouting && | ||
s1.SelfSignedCert == s2.SelfSignedCert | ||
s1.SelfSignedCert == s2.SelfSignedCert && | ||
s1.DevMode == s2.DevMode | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
const ( | ||
recreateClusterUsage = "Delete cluster first if it already exists." | ||
buildNameUsage = "Name for build (Prefix for kind cluster name, pod names, etc)." | ||
devModeUsage = "When enabled, the platform will run the core packages with developer password." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If this is the case, then we should install gitea and argocd using a non generated password ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What about using the the parameter: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am ok with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finally we aligned our paths => I will then use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear, I meant to have two flags. ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be fair is the The only argument I could maybe gather is that since it is no longer than admin credentials and it is developer credentials that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I still think this needs to be the case. |
||
kubeVersionUsage = "Version of the kind kubernetes cluster to create." | ||
extraPortsMappingUsage = "List of extra ports to expose on the docker container and kubernetes cluster as nodePort " + | ||
"(e.g. \"22:32222,9090:39090,etc\")." | ||
|
@@ -40,6 +41,7 @@ var ( | |
// Flags | ||
recreateCluster bool | ||
buildName string | ||
devMode bool | ||
kubeVersion string | ||
extraPortsMapping string | ||
kindConfigPath string | ||
|
@@ -67,6 +69,7 @@ func init() { | |
CreateCmd.PersistentFlags().StringVar(&buildName, "build-name", "localdev", buildNameUsage) | ||
CreateCmd.PersistentFlags().MarkDeprecated("build-name", "use --name instead.") | ||
CreateCmd.PersistentFlags().StringVar(&buildName, "name", "localdev", buildNameUsage) | ||
CreateCmd.PersistentFlags().BoolVar(&devMode, "dev-mode", false, devModeUsage) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add another flag here with the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok but then what will be the purpose of the flag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
CreateCmd.PersistentFlags().StringVar(&kubeVersion, "kube-version", "v1.30.3", kubeVersionUsage) | ||
CreateCmd.PersistentFlags().StringVar(&extraPortsMapping, "extra-ports", "", extraPortsMappingUsage) | ||
CreateCmd.PersistentFlags().StringVar(&kindConfigPath, "kind-config", "", kindConfigPathUsage) | ||
|
@@ -143,6 +146,7 @@ func create(cmd *cobra.Command, args []string) error { | |
IngressHost: ingressHost, | ||
Port: port, | ||
UsePathRouting: pathRouting, | ||
DevMode: devMode, | ||
}, | ||
|
||
CustomPackageDirs: absDirPaths, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
"io" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/cnoe-io/idpbuilder/api/v1alpha1" | ||
|
@@ -206,6 +207,18 @@ func secretToTemplateData(s v1.Secret) TemplateData { | |
for k, v := range s.Data { | ||
data.Data[k] = string(v) | ||
} | ||
|
||
// TODO: The following code should be reviewed and improved as the secret containing the developer username/password is argocd-secret | ||
// where the password has been bcrypted and by consequence we cannot get and decode it from the secret | ||
// This is why we are going to add it here BUT it will be displayed every time no matter if --dev-mode has been used or not | ||
if strings.Contains(s.Name, "gitea") { | ||
data.Data["username-developer"] = "giteAdmin" | ||
data.Data["password-developer"] = "developer" | ||
} else if strings.Contains(s.Name, "argocd") { | ||
data.Data["username-developer"] = "developer" | ||
data.Data["password-developer"] = "developer" | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can get the localbuild object from K8s since it's essentially our way of storing configurations. You added the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes but the flag |
||
return data | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,10 @@ func (r *RepositoryReconciler) reconcileGitRepo(ctx context.Context, repo *v1alp | |
return ctrl.Result{}, fmt.Errorf("getting git provider credentials: %w", err) | ||
} | ||
|
||
if r.Config.DevMode { | ||
creds.password = "developer" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use the string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed: 570ca30 |
||
} | ||
|
||
err = provider.setProviderCredentials(ctx, repo, creds) | ||
if err != nil { | ||
return ctrl.Result{}, fmt.Errorf("setting git provider credentials: %w", err) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,12 @@ package localbuild | |
import ( | ||
"context" | ||
"embed" | ||
|
||
"fmt" | ||
"github.com/cnoe-io/idpbuilder/api/v1alpha1" | ||
"github.com/cnoe-io/idpbuilder/globals" | ||
"github.com/cnoe-io/idpbuilder/pkg/k8s" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
|
@@ -15,6 +17,13 @@ import ( | |
//go:embed resources/argo/* | ||
var installArgoFS embed.FS | ||
|
||
const ( | ||
argocdDevModePassword = "developer" | ||
argocdInitialAdminSecretName = "argocd-initial-admin-secret" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this to globals. We reference these in the get command too. |
||
argocdNamespace = "argocd" | ||
argocdIngressURL = "%s://argocd.cnoe.localtest.me:%s" | ||
) | ||
|
||
func RawArgocdInstallResources(templateData any, config v1alpha1.PackageCustomization, scheme *runtime.Scheme) ([][]byte, error) { | ||
return k8s.BuildCustomizedManifests(config.FilePath, "resources/argo", installArgoFS, scheme, templateData) | ||
} | ||
|
@@ -57,3 +66,20 @@ func (r *LocalbuildReconciler) ReconcileArgo(ctx context.Context, req ctrl.Reque | |
resource.Status.ArgoCD.Available = true | ||
return ctrl.Result{}, nil | ||
} | ||
|
||
func (r *LocalbuildReconciler) ArgocdInitialAdminSecretObject() corev1.Secret { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this needs to be exported. This is more like a utility function. Since we do something like this in the get command, we should move this to the util package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be moved to utils. |
||
return corev1.Secret{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "Secret", | ||
APIVersion: "v1", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: argocdInitialAdminSecretName, | ||
Namespace: argocdNamespace, | ||
}, | ||
} | ||
} | ||
|
||
func (r *LocalbuildReconciler) ArgocdBaseUrl(config v1alpha1.BuildCustomizationSpec) string { | ||
return fmt.Sprintf(argocdIngressURL, config.Protocol, config.Port) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field should be
StaticPasswords
. We need to make an effort to make what these fields do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: 35fc902