Tutorial: Getting Started with Self Signed Certificates

Getting started

In this tutorial, we will use the Self Signed Certificates charm to provide certificates to a requiring charm using the TLS Certificates Requirer Operator as our TLS certificates requirer.

1. Install pre-requisites

Install MicroK8s:

sudo snap install microk8s

Enable the hostpath-storage MicroK8s add-on:

microk8s enable hostpath-storage

Install Juju:

sudo snap install juju

2. Bootstrap a Juju controller

Bootstrap a Juju controller:

juju bootstrap microk8s

Create a Juju model:

juju add-model demo

3. Deploy Self Signed Certificates

juju deploy self-signed-certificates

4. Deploy tls-certificates-requirer

juju deploy tls-certificates-requirer --channel=edge

5. Integrate the two charms

Integrate the charms with their tls-certificates interface:

juju integrate self-signed-certificates tls-certificates-requirer

Wait for both charms to be in the active/idle status.

ubuntu@server:~$ juju status
Model  Controller          Cloud/Region        Version  SLA          Timestamp
demo   microk8s-localhost  microk8s/localhost  3.1.7    unsupported  08:41:14-05:00

App                        Version  Status  Scale  Charm                      Channel  Rev  Address        Exposed  Message
self-signed-certificates            active      1  self-signed-certificates   stable    57  10.152.183.96  no       
tls-certificates-requirer           active      1  tls-certificates-requirer  edge      28  10.152.183.45  no       Certificate is available

Unit                          Workload  Agent  Address      Ports  Message
self-signed-certificates/0*   active    idle   10.1.182.39         
tls-certificates-requirer/0*  active    idle   10.1.182.21         Certificate is available

6. Retrieve the TLS Certificates

Use the TLS Certificates Requirer’s get-certificate action to retrieve the certificate it received from Self Signed Certificates:

juju run tls-certificates-requirer/0 get-certificate

You should expect this output (with different certificates of course):

ubuntu@server:~$ juju run tls-certificates-requirer/0 get-certificate
Running operation 1 with 1 task
  - task 2 on unit-tls-certificates-requirer-0

Waiting for task 2...
ca-certificate: |-
  -----BEGIN CERTIFICATE-----
  MIIDZzCCAk+gAwIBAgIUbjeqQUknRGtZeNdncwSLHym/rpMwDQYJKoZIhvcNAQEL
  BQAwOTELMAkGA1UEBhMCVVMxKjAoBgNVBAMMIXNlbGYtc2lnbmVkLWNlcnRpZmlj
  YXRlcy1vcGVyYXRvcjAeFw0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gZ1YrCGylAb+D6d01U2mpt7yASW4lIW6oqQKV2z02k1E
  Puf4y3KcZ61TPr8vRQs4aj+k4voG55OxYkbrRCaQJ+AaV8YFVXbT29r3hobUwfqm
  UnU4
  -----END CERTIFICATE REQUEST-----

Good job, you successfully used the Self Signed Certificates charm to provide charm to a requiring charm.

7. Destroy the environment

Kill the Juju controller:

juju kill-controller microk8s-localhost

Uninstall the Juju and MicroK8s snaps:

sudo snap remove microk8s juju --purge

are there any hardware requirements for this charm? i couldnt find it anywhere in the documentation. I use an arm64 machine, and the charm doesn’t seem to be working. I see the pod is stuck in pending state due to the nodeSelector being specified as amd64. Could you help clarify this?

Hello @swetha1654 ,

The charm should work on an arm machine and it is a very small charm (no workload) so if any charm can be deployed on any machine, it’s this one. Unfortunately, I don’t have an arm machine myself to confirm this but my colleague @ghibourg was able to build it and run it on his raspberry PI as far as I remember. What are your machine specifications and which version of the charm are you deploying? Please also provide the output of juju status.

@ghibourg , is there any special juju trick to get the charm deployed on arm?

Thanks,

Guillaume

Hi @gruyaume I figured out my mistake. I had to run the command-

juju deploy postgresql-k8s --trust --constraints “arch=arm64”

i did not provide the constraints previously. The documentation mentioned that it will be available from revision 211+ and when i installed postgresql charm it showed that revision 381 was installed so i assumed that the support would automatically be available.

Just want one clarification. Is this "constraints " parameter documented somewhere? I couldn’t find it anywhere.

1 Like

Hello, glad you found the issue, I was just about to write about the constraints. It is documented in the Juju documentation, but I am not sure the full behavior is well explained there. If no arch constraints is provided at deployment, Juju will automatically add arch=amd64 to the constraints.

This is why it works properly when running on amd64 but breaks on arm64 if the constraints is not specified. As you found, it will have the same behavior for all charms for that architecture.

1 Like

could you point out where it is in the documentation? that would be helpful, thanks!

Juju constraints are listed here.

1 Like