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

Add support for private registry on Megalos #282

Conversation

GioBar00
Copy link

@GioBar00 GioBar00 commented Mar 28, 2024

- What I did

  • Added new Kubernetes setting private_registry_dockerconfigjson for a base64-encoded docker configuration.
  • When creating a namespace, if the setting above is set, create also a Kubernetes secret named private-registry of type kubernetes.io/dockerconfigjson.
  • When creating the machines, if the setting above is set, add the image_pull_secret argument to the pod specification referring to the private-registry secret.

- How I did it

  • Edited KubernetesSettingsAddon.py to add the new setting private_registry_dockerconfigjson.
  • Edited KubernetesOptionHandler.py to add the cli menu to enter or delete the setting.
  • Edited KubernetesNamespace.py to create the private-registry secret if the setting is set right after creating the namespace.
  • Edited KubernetesMachine.py to add the image_pull_secret argument to the pod specification referring to the private-registry secret if the setting is set.

- How to verify it
Create a private registry and get the docker config. Example of the file structure:

{
    "auths": {
        "https://index.docker.io/v1/": {
            "auth": "c3R...zE2"
        }
    }
}

Compute the base64 encoding of the docker config and add it to Kathara settings.
Deploy a lab with kathara lstart or a machine with kathara vstart with an image available on the private registry.

- Description for the changelog

Added support for private registries on Megalos

Resolves #283.

@GioBar00
Copy link
Author

- Why
It allows to use images that someone might not want to give public access to.
It is necessary to add this feature directly to Kathará since there is no straight forward way to do it separately.
Kubernetes secrets are namespaced so one would need to create the Kubernetes secret after the namespace is created, but before the pods are deployed. This is not possible when deploying a lab in Kathará since the machines are created right after the namespace is.

@GioBar00 GioBar00 marked this pull request as ready for review March 28, 2024 15:04
@GioBar00 GioBar00 changed the title Add support for private container registry on Megalos Add support for private registry on Megalos Mar 28, 2024
Copy link
Member

@Skazza94 Skazza94 left a comment

Choose a reason for hiding this comment

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

Hi @GioBar00.
thanks for the PR and sorry for the delay.

I suggest some changes on your code that I would like to discuss before merging the PR.

Thanks,
Mariano.

src/Kathara/cli/ui/setting/KubernetesOptionsHandler.py Outdated Show resolved Hide resolved
src/Kathara/setting/addon/KubernetesSettingsAddon.py Outdated Show resolved Hide resolved
src/Kathara/manager/kubernetes/KubernetesNamespace.py Outdated Show resolved Hide resolved
src/Kathara/manager/kubernetes/KubernetesMachine.py Outdated Show resolved Hide resolved
src/Kathara/cli/ui/setting/KubernetesOptionsHandler.py Outdated Show resolved Hide resolved
@GioBar00
Copy link
Author

GioBar00 commented May 27, 2024

I modified the code with the suggestions above.

…specified file and store as base64 string. Added Docker Config JSON Validator and related exception. Added default value option in setting-utils `read_value`. Added custom read for docker config json.
@Skazza94
Copy link
Member

Hi @GioBar00,
thank you very much!

I will check the changes tomorrow and if everything is ok I will merge the PR in the develop branch for the next release.

@Skazza94 Skazza94 changed the base branch from develop to 283-private-registry-support-on-megalos May 30, 2024 11:17
@tcaiazzi tcaiazzi added this to the Release 3.7.7 milestone Jul 5, 2024
Copy link
Member

@Skazza94 Skazza94 left a comment

Choose a reason for hiding this comment

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

Hi @GioBar00,
PR is ok.

The only thing is that tests are missing. Can you provide some test suites for the new
KubernetesSecret class, the changes in KubernetesNamespace and test the case in KubernetesMachine when the private config json is provided?

Thanks.

src/Kathara/validator/DockerConfigJSONValidator.py Outdated Show resolved Hide resolved
…nd InvalidDockerConfigJSONError to InvalidDockerConfigJsonError
@Skazza94
Copy link
Member

Skazza94 commented Sep 6, 2024

Hey @GioBar00,
do you plan to add some tests for the new feature?

Otherwise, we could merge the PR and write them by ourselves to speed up the feature addition! 😄

Thanks,
Mariano.

@GioBar00
Copy link
Author

GioBar00 commented Sep 6, 2024

Sorry, currently I do not have time to look into it myself.
Proceed with the merge.
Sorry again and thanks 👍

@Skazza94 Skazza94 merged commit e8fa40f into KatharaFramework:283-private-registry-support-on-megalos Sep 11, 2024
@Skazza94 Skazza94 removed this from the Release 3.7.7 milestone Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants