Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

added option to authenticate with registry #88

Merged
merged 5 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ Instead of using Docker Compose, you can deploy Clearwater in Kubernetes. This r

e.g. `kubectl create configmap env-vars --from-literal=ZONE=default.svc.cluster.local --from-literal=ADDITIONAL_SHARED_CONFIG=hss_hostname=hss.example.com\\nhss_realm=example.com`

- If you're using a private container registry (one that requires credentials to pull images from), create a secret with the required credentials. e.g. `kubectl create secret docker-registry myregistrykey --docker-server=$DOCKER_REGISTRY_SERVER --docker-username=$DOCKER_USER --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL`
- Update the Kubernetes yaml to match your deployment.

- Generate the Kubernetes yaml files from the templates by going to the kubernetes directory and running `./k8s-gencfg --image_path=<path to your repo> --image_tag=<tag for the images you want to use>`
If you're using a private container registry, add the argument `--image_secret=myregistrykey` (where `myregistrykey` matches the secret you made earlier)
The script assumes that the Clearwater images that you want to use are located at {{image_path}}/\<image name e.g. bono\>:{{image_tag}}. It will also generate a helm chart in `/kubernetes/clearwater`.

- Decide how you want to access Bono and Ellis from outside of the cluster.
Expand Down
2 changes: 1 addition & 1 deletion homestead-prov/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM clearwater/base
MAINTAINER maintainers@projectclearwater.org

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes homestead-prov clearwater-prov-tools
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes homestead homestead-prov clearwater-prov-tools
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this has probably come in from a different set of changes. Would be good to revert this change here to keep the PR clean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah woops. Yes that's my mistake for not keeping my repos clean and separated. I'll fix that.


COPY homestead-prov.supervisord.conf /etc/supervisor/conf.d/homestead-prov.conf
COPY nginx.supervisord.conf /etc/supervisor/conf.d/nginx.conf
Expand Down
14 changes: 13 additions & 1 deletion kubernetes/k8s-gencfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ def parse_file(args, input_file, output_file):
with open(input_file) as file:
input_data = file.read()

output_data = input_data.replace("{{IMAGE_PATH}}", args.image_path).replace("{{IMAGE_TAG}}", args.image_tag)
data = input_data.replace("{{IMAGE_PATH}}", args.image_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason for splitting this? I think we'd probably prefer to keep this as a single line given the templating is also a single line to change. Helps to keep the concepts in sync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just thought that putting it in a single line leads to a line which is too long, which I consider bad style. I'm happy to change it to one line if you want.

data = data.replace("{{IMAGE_TAG}}", args.image_tag)

# this argument is optional
# ~ means null in yaml
output_data = data.replace("{{IMAGE_SECRET}}", args.image_secret if (args.image_secret != None) else "~")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll probably try this out a bit on our rigs, to make sure it behaves as i'm expecting, but can you give a summary of any testing/checking you've done here on if there isn't a secret provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't done proper testing of the no secret case, because I don't have a public repo. I did try running it on my private repo, and it seemed to parse fine and then give an authentication failed error.

Today I created a public docker hub repo. I'll try on that when I get a chance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it does work with no authentication. I just tried.




Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to clean up the unnecessary blank lines here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep I'll fix that.


with open(output_file, "w") as file:
file.write(output_data)
Expand All @@ -27,6 +35,7 @@ def parse_files_in_dir(args, src, dest):

parse_file(args, os.path.join(src, template_file_name), os.path.join(dest, template_name+".yaml"))


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
Expand All @@ -35,6 +44,9 @@ if __name__ == '__main__':
parser.add_argument(
'--image_tag', required=True,
help='The image tag to use')
parser.add_argument(
'--image_secret', required=False,
help='(Optional) The kubernetes secret for authenticating with the container registry')
args = parser.parse_args()

# Create kubernetes manifests
Expand Down
2 changes: 2 additions & 0 deletions kubernetes/templates/astaire-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ spec:
volumes:
- name: astairelogs
emptyDir: {}
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/bono-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ spec:
volumes:
- name: bonologs
emptyDir: {}
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/cassandra-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ spec:
readinessProbe:
exec:
command: ["/bin/bash", "/usr/share/kubernetes/liveness.sh", "7000 9042 9160"]
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/chronos-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ spec:
volumes:
- name: chronoslogs
emptyDir: {}
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/ellis-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ spec:
readinessProbe:
tcpSocket:
port: 80
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/etcd-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ spec:
readinessProbe:
tcpSocket:
port: 4001
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/homer-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ spec:
readinessProbe:
tcpSocket:
port: 7888
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/homestead-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ spec:
volumes:
- name: homesteadlogs
emptyDir: {}
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/homestead-prov-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ spec:
readinessProbe:
exec:
command: ["/bin/bash", "/usr/share/clearwater/bin/poll_homestead-prov.sh"]
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/ralf-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ spec:
volumes:
- name: ralflogs
emptyDir: {}
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always
2 changes: 2 additions & 0 deletions kubernetes/templates/sprout-depl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ spec:
volumes:
- name: sproutlogs
emptyDir: {}
imagePullSecrets:
- name: {{IMAGE_SECRET}}
restartPolicy: Always