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

Changes the K8s-cronjob to a sidecar #206

Closed
wants to merge 1 commit into from

Conversation

sistason
Copy link

Fixes #204 by migrating the r10k cronjobs to sidecars
The sidecar is using crond, while still respecting all values.yaml options from the cronjob

Fixes puppetlabs#204 by migrating the r10k cronjobs to sidecars
The sidecar is using crond, while still respecting all values.yaml options from the cronjob
@sistason sistason requested a review from a team as a code owner February 20, 2020 13:47
@Xtigyro Xtigyro self-assigned this Mar 31, 2020
@Xtigyro
Copy link
Contributor

Xtigyro commented Mar 31, 2020

Hey @sistason - thank you very much for the nice contribution!

We agree that this is the way to go though it will be utilized usefully only when the support for multiple Puppet masters running on different K8s nodes lands in the chart.

We're gonna review the PR in the coming days. Thank you once more! It's appreciated!

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 11, 2020

Hey @sistason - I tested it today but I couldn't make it work.
Firstly, there's nothing in the directory where the Puppet Control repo should be synced:

/opt # ls -ltrah /etc/puppetlabs/code/environments/production/
total 8
drwxr-xr-x    3 puppet   ping        4.0K Apr 11 19:08 ..
drwxr-x---    2 puppet   ping        4.0K Apr 11 19:08 .

And it appears not to be able to clone a remote repo:

/home/puppet # /opt/r10k.cronjob.sh
ERROR    -> Unable to determine current branches for Git source 'puppet_repo' (/etc/puppetlabs/code/environments)
Original exception:
Command exited with non-zero exit code:
Command: git clone --mirror [email protected]:Xtigyro/puppet-control-repo.git /etc/puppetlabs/code/r10k_cache/[email protected]
Stderr:
Cloning into bare repository '/etc/puppetlabs/code/r10k_cache/[email protected]'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Exit code: 128
1

Secondly, using root as the run-user is an anti-pattern and we try to avoid it.
Lastly, we've updated the chart to support Helm v3. Some refactoring is required.

Do you think you can try to work on those points? Or can we work together?

Let me know please - so we organize our efforts efficiently.
You can msg me in the Puppet Community Slack workspace.

And thanks once again for the contribution!

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 11, 2020

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 12, 2020

@underscorgan @sistason It appears we can achieve running r10k at a certain schedule without being the superuser. It can be done by using supercronic. The one small thing that is missing is to optionally exit when the job that it run failed.

An issue has been filed to the creators of that awesome tool: aptible/supercronic#60

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 13, 2020

For reference purposes - the PR which adds supercronic to the r10k official Docker image.
-- puppetlabs/r10k#1043

@sistason
Copy link
Author

I won't be able to put much time in here, also since I have no idea of puppet, just K8s...

  • The cronjob-sidecar just uses git/r10k, I cannot help with debugging there, but will ask around
  • for helm3/securityContext I'll look at what you changed lately and adapt to that

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 14, 2020

I won't be able to put much time in here, also since I have no idea of puppet, just K8s...

* The cronjob-sidecar just uses git/r10k, I cannot help with debugging there, but will ask around

* for helm3/securityContext I'll look at what you changed lately and adapt to that

No worries - the issues have been overcome. Thanks for the reply and your time.

CC - @slconley @underscorgan

@sistason
Copy link
Author

The issues overcome? via supercronic?

Could you tell me again what I can contribute here, so we're on the same page? :)
If there is nothing left, that's also okay ;)

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 15, 2020

The issues overcome? via supercronic?

Could you tell me again what I can contribute here, so we're on the same page? :)
If there is nothing left, that's also okay ;)

Via supercronic and changing the code.
You can definitely test it - that would be useful! -- https://github.com/Xtigyro/puppetserver-helm-chart/tree/edge
Please for the r10k Docker image use (as the PR in the r10k has not been merged just yet):

r10k:
  image: xtigyro/r10k
  tag: 0.2

@kubicgruenfeld
Copy link

Via supercronic and changing the code.
You can definitely test it - that would be useful! -- https://github.com/Xtigyro/puppetserver-helm-chart/tree/v310
Please for the r10k Docker image use (as the PR in the r10k has not been merged just yet):

i did test the code in the v310 branch and the r10k image but we have still the same issue. the cronjob tries to attach a pvc which is already bound to the puppetserver.

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 16, 2020

Via supercronic and changing the code.
You can definitely test it - that would be useful! -- https://github.com/Xtigyro/puppetserver-helm-chart/tree/v310
Please for the r10k Docker image use (as the PR in the r10k has not been merged just yet):

i did test the code in the v310 branch and the r10k image but we have still the same issue. the cronjob tries to attach a pvc which is already bound to the puppetserver.

@kubicgruenfeld Are you sure you've tested the code from that branch? There's no cronjob in it.

@kubicgruenfeld
Copy link

Maybe I missed something. Will check again.

@kubicgruenfeld
Copy link

@Xtigyro i tested again and you were right, i was on the wrong branch.

But there are still some bits not working as expected. I have the configmap r10k-code-config but the mount to /etc/puppetlabs/puppet/r10k.yaml does not seem to be working. I had a look through the code and as far as i can tell, this should work.

And if running ~/.r10k_code_cronjob.out i also get this, which seems strange:

...
Running /docker-entrypoint.d/70-set-dns-alt-names.sh
Running /docker-entrypoint.d/80-ca.sh
Running /docker-entrypoint.d/85-setup-storeconfigs.sh
Running /docker-entrypoint.d/90-consul.sh
puppetserver: 'deploy' is not a puppetserver command. See 'puppetserver --help'.

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 17, 2020

@kubicgruenfeld Could you please verify whether a Puppet Agent can connect and deploy your Puppet/Hiera code?

There's a section in the README which you can literally copy-paste to test it, too: https://github.com/Xtigyro/puppetserver-helm-chart/tree/v310#testing-the-deployed-chart-resources

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 17, 2020

@kubicgruenfeld In the meantime, I'll try to fix the non-working /etc/puppetlabs/puppet/r10k.yaml - confirmed.

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 17, 2020

@kubicgruenfeld In the meantime, I'll try to fix the non-working /etc/puppetlabs/puppet/r10k.yaml - confirmed.

@kubicgruenfeld Both issues should be fixed. Could you please re-test?

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 17, 2020

Found one other small issue which was related to the previous two ones - fixed.

The chart v3.1 should be very soon good to go live!

CC: @underscorgan @slconley

@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 19, 2020

@underscorgan @slconley @kubicgruenfeld @sistason @baurmatt
I think we're good to go here. If nobody has found any new bugs - we should be releasing v3.1.0 when the official r10k Docker image bundled with supercronic is released.

@Xtigyro Xtigyro added enhancement New feature or request helm chart labels Apr 19, 2020
@Xtigyro
Copy link
Contributor

Xtigyro commented Apr 20, 2020

@sistason Could you please review the following PR in your fork: syseleven#1

CC: @underscorgan @slconley

@Xtigyro
Copy link
Contributor

Xtigyro commented May 5, 2020

Closing this as the chart has been moved to its own GitHub repo at: https://github.com/puppetlabs/puppetserver-helm-chart

@Xtigyro Xtigyro closed this May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request helm chart
Projects
None yet
Development

Successfully merging this pull request may close these issues.

k8s, code/hiera deployment isn't working because of ReadWriteOnce volume
3 participants