Git Product home page Git Product logo

cert-operator's Introduction

An Operator for Automated Certificate Lifecycle in OpenShift

Prerequisites

Installation

git clone [this repo]
dep ensure

Local Run for Development

oc login ...
oc new-project cert-operator
export OPERATOR_NAME=cert-operator
operator-sdk up local

Running Test Cases

oc login ...
oc new-project cert-operator-test
export OPERATOR_NAME=cert-operator
operator-sdk test local ./test/e2e/ --namespace=cert-operator-test --up-local

Deployment to OpenShift

oc process -f build/build.yml | oc apply -f-
oc apply -f deploy/service_account.yaml
oc apply -f deploy/role.yaml
oc apply -f deploy/role_binding.yaml
oc apply -f deploy/deployment.yaml

Configuration

The operator is configured via a combination of environment variables and a configuration file. The majority of the config can be placed in a YAML formatted config file. The configuration file is loaded by searching in the following locations, with those at the top taking priority:

  • value of CERT_OP_CONFIG environment variable

  • /etc/cert-operator/config.yml

General Config

The cert operator uses annotations on the various resources it manages to decide what actions are required. The annotations that are used are configurable via the config file. The default values are as follows:

general:
  annotations:
    status: openshift.io/cert-ctl-status
    status-reason: openshift.io/cert-ctl-status-reason
    expiry: openshift.io/cert-ctl-expires
    format: openshift.io/cert-ctl-format

Certificate Providers

The cert operator provides a pluggable architecture for supporting multiple certificate providers. The following is the set of current and planned providers.

Supported Providers
  • ✓ NoneProvider(none) - A mock provider for testing which returns empty values

  • ✓ SelfSignedProvider(self-signed) - Delivers self-signed certificates

  • ❏ LetsEncryptProvider(lets-encrpyt) - A free and open public CA

  • ❏ FreeIPAProvider(ipa) - An open source identity management system

  • [X] VenafiProvider(venafi) - An Enterprise PKI product

Configuring which provider is used is a matter of adding the following to your config.yml:

provider:
  kind: <name>
  ssl: <true/false>

Certificate Formats

This operator currently supports the following certificate formats.

Supported Formats
  • ✓ PEM - default

  • ✓ PKCS12

Notifications

This operator currently supports sending notifications via ChatOps. The following is the set of current and planned providers.

Supported Notifiers
  • ✓ Slack

  • ❏ RocketChat

To configure sending notifications, set the following environment variables:

NOTIFIER_TYPE="slack"
<NOTIFIER>_WEBHOOK_URL="https://example.webhook.com/bla/blah"

Testing Functionality

This operator will create certificates for routes and services. To test this functionality, first create a new application.

oc new-app --template dotnet-example

Create a Certificate for a Route

Annotate the route to tell the operator it needs a cert.

oc annotate route dotnet-example openshift.io/cert-ctl-status=new --overwrite

In the logs for your operator, you’ll see something like:

{"level":"info","ts":1553713448.1514533,"logger":"controller_route","msg":"Reconciling Route","Request.Namespace":"cert-operator","Request.Name":"dotnet-example"}
{"level":"info","ts":1553713448.2551682,"logger":"controller_route","msg":"Updated route with new certificate","Request.Namespace":"cert-operator","Request.Name":"dotnet-example"}

Then, if you take a look at your dotnet-example route, you’ll see that it has been update with a TLS Edge policy.

$ oc get route dotnet-example -o yaml
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  annotations:
    openshift.io/managed.cert: "secured"
...
  name: dotnet-example
spec:
...
  tls:
    certificate: |
      -----BEGIN CERTIFICATE-----
      ...
      -----END CERTIFICATE-----
    key: |
      -----BEGIN RSA PRIVATE KEY-----
      ...
      -----END RSA PRIVATE KEY-----
    termination: edge
    ...

Create a Certificate for a Service (SSL-to-Pod)

Annotate the service to tell the operator it needs a cert. The default certificate format will be PEM unless you first create an annotation of "openshift.io/cert-ctl-format" with a Supported Certificate Formats above.

oc annotate service dotnet-example openshift.io/cert-ctl-status=new --overwrite

In the logs for your operator, you’ll see something like:

{"level":"info","ts":1553715427.6889565,"logger":"controller_service","msg":"Reconciling Service","Request.Namespace":"cert-operator","Request.Name":"dotnet-example"}
{"level":"info","ts":1553715427.8858836,"logger":"controller_service","msg":"Updated service with new certificate","Request.Namespace":"cert-operator","Request.Name":"dotnet-example"}

Look to see that a new secret has been created in your project.

$ oc get secret | grep dotnet-example
dotnet-example-certificate             Opaque                                2         23m

You’ll also notice that the annotation on the service has changed.

$ oc get service dotnet-example -o jsonpath='{.metadata.annotations.openshift\.io/cert-ctl-status}'
secured

Create a Certificate for a Service (SSL-to-Pod) PKCS12 format

Annotate the service to tell the operator it needs a cert. The default certificate format will be PEM unless you first create an annotation of format "openshift.io/cert-ctl-format"

oc annotate service dotnet-example openshift.io/cert-ctl-format=pkcs12 --overwrite
oc annotate service dotnet-example openshift.io/cert-ctl-status=new --overwrite

You will notice two entries in the secret "tls.p12" and "tls-p12-secret.txt"

cert-operator's People

Contributors

boydvan131 avatar etsauer avatar gl4di4torrr avatar kkoller avatar mathianasj avatar sysmatrix1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cert-operator's Issues

add support for namespaced issuers

it should be possible to be able to define team-level credential for connection to CAs as opposed to cluster level one.
This allows better multi-tenancy and accountability on the CAs side.

Explicitly fail passthrough route.

Fail passthrough route as certificate is not supported. The current behavior is to request a certificate for passthrough route, try to set it and fail. This possibly would result in a loop.

JSON logging

Operator logs should be in JSON format or have the option to be properly parsed by Sumologic.

Image build failing undefined: memory.WithData

Trying to build this into an image and its failing due to : github.com/redhat-cop/cert-operator/pkg/config/config.go:75:3: undefined: memory.WithData. Seems like WithData is no longer a valid method in the memory package.

Explicitly fail cert on service when secret is not of type TLS

Secrets type cannot be change when a cert is requested on a passthrough, if a secret already exist and isn't of type TLS. The service secret cannot be set. The cert operator will fail and will retry in loop to set a new cert on the service.

The solution that will be applied is to check for the secret type if it exist and if it's not of type TLS mark the service cert request as failed.

Add e2e testing for venafi provider

We recently had something break, and did not know it did. I would like to see an e2e test developed for the venafi provider. It looks like its possible to use a venafi cloud account to test this independently.

#venafi -- add support for additional metadata

This is a request from a customer.
venafi apparently supports the ability to pas additional metadata when requesting a certificate (I can't find the official API documentation).
This metadata will be used to associate the certificate to the right team.

use standard `kubernetes.io/tls` secret

Hi!

I am testing 0.2.0 version and as I can see operator produce just regular secret.
Kubernetes has a standard secret type for TLS, I believe the operator should produce kubernetes.io/tls secrets.

how to create TLS secret manually:

kubectl create secret tls cluster3-certificate --cert=./server-cert.pem --key=./server-key.pem

Upgrade to operator-sdk v0.8.1

The cert-operator can no longer be build under the latest version of the operator-sdk. Currently it is being build against master.
This issue is to upgrade the cert-operator to use the latest libraries needed by the latest version of the operator-sdk.

Warn on hostnames over 64 characters

Hostnames/common-name cannot be over 64 characters (see RFC 3280 page 103). We should provide a warning when requesting a CSR over 64 characters

Integrate with Cert Manager

We would like to explore how we might use this project as a wrapper around Jetstack Cert Manager. This project is gaining a lot of traction, even getting PKI vendors to contribute plugins. what they don't have is support for OpenShift, specifically routes.

Manage OCP certs: OCP console & OCP Routers?

Hey, this project seems very interesting.

One question, is this operator only for Apps, or also for cluster certs, such as the Console or the routers?

It would bee very useful to have an operator to automatically manage cluster certs ;).

deploy/deployment.yaml is missing

In the README has the following step:
oc apply -f deploy/deployment.yaml

However, there is no deployment.yaml file. Maybe, this step should be oc apply -f deploy/operator.yaml?

The deployment.yaml deleted by issue#26 so the README need to update.

Refactor logging to use logrus

Follwing this operator as an example, we should swap out the default logger for logrus, as it gives us better support for log levels.

Support addition of ca-certificates via secrets

Rather than baking a PEM file into our main docker image to add a trusted certificate, we should be mounting those into the container at runtime, and use a start script to run the update-ca-certificates command.

Can't use go-config beyond version 0.7.0

Description of Issue

After go-config v0.7.0, our operator breaks on startup citing that there is no provider configured.

How to Reproduce

Update the following constraint in Gopkg.toml from 0.7.0 to any later release:

[[constraint]]
  name = "github.com/micro/go-config"
  version = "0.7.0"

Install dependencies and start operator:

dep ensure
operator-sdk up local

Expected result

Operator starts successfully

Actual Result

panic: There was a problem detecting which provider to configure. 
	Provider kind `` is invalid. 
{"provider":{"kind":""},"general":{"annotations":{"status":"","status-reason":"","expiry":"","format":""}}}

goroutine 1 [running]:
github.com/redhat-cop/cert-operator/pkg/stub.NewHandler(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/esauer/go/src/github.com/redhat-cop/cert-operator/pkg/stub/handler.go:32 +0x30e
main.main()
	/home/esauer/go/src/github.com/redhat-cop/cert-operator/cmd/cert-operator/main.go:33 +0x177
exit status 2
Error: failed to run operator locally: exit status 1

Null check for TLSTermination in route.

TLSTerminationType may be null on a route. There should a null check on termination before checking for passthrough type. If the termination type is null, it should be defaulted to Edge.

Build a sample pipeline to build and deploy operator to OpenShift clusters

In order to help with organizations looking to adopt the operator, want to provide a good method for them to get it built and deployed. To help with this, we want to build a sample deployment pipeline that includes:

  • A Jenkinsfile that handles the go build and image build of the operator
  • A template to manage the pipeline build
  • A template to manage deployment to openshift clusters
  • An Applier inventory to manage the lifecycle of the resources.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.