Coder Social home page Coder Social logo

freeipa-operator's Introduction

freeipa-operator

Experimental freeipa-operator for Freeipa.

Quick Start

It requires golang 1.16; if your system is providing a lower version, consider to install gvm. for using different golang versions.

  1. Clone the repository by:

    git clone https://github.com/freeipa/freeipa-operator.git
    cd freeipa-operator
  2. Install the necessary tools by:

    ./devel/install-local-tools.sh
  3. Build by:

    make build
  4. Launch tests by:

    make test
    ./bin/operator-sdk scorecard bundle
  5. Now create a new namespace by: oc create namespace my-freeipa

  6. As cluster-admin user logged in the cluster run:

    make install

    This will generate the CRD and install it into the cluster. The CRD need to be installed into the cluster even if we run the controller from our local workstation.

  7. Run locally outside the cluster by (webhooks are disabled):

    make run
  8. Or run inside the cluster by (first build and push the image):

    oc login https://my-cluster:6443
    export IMAGE_TAG_BASE=quay.io/USER_ORG/freeipa-operator
    podman login quay.io
    make docker-build
    make docker-push
    
    # We need cert-manager for generating the certificates for the webhooks
    make cert-manager-install
    # When the cert-manager operator is installed, run this:
    make cert-manager-self-signed-issuer-create
    
    # Create the scc object
    oc create -f config/rbac/scc.yaml
    
    # Finally deploy the operator in the cluster with:
    make deploy
  9. Create private.mk file and update IMG_BASE variable value.

    cp -vf private.mk.example private.mk

    Update private.mk where required

  10. And create a new idm resource by:

    make sample-create

    The deployment spend about 5 minutes to finish, after that you will see something like the below when running: oc logs --tail=35 pod/idm-sample-main-0

    [  OK  ] Finished Identity, Policy, Audit.
    ==============================================================================
    Setup complete
    
    Next steps:
       1. You must make sure these network ports are open:
          TCP Ports:
            * 80, 443: HTTP/HTTPS
            * 389, 636: LDAP/LDAPS
            * 88, 464: kerberos
          UDP Ports:
            * 88, 464: kerberos
    
       2. You can now obtain a kerberos ticket using the command: 'kinit admin'
          This ticket will allow you to use the IPA tools (e.g., ipa user-add)
          and the web user interface.
       3. Kerberos requires time synchronization between clients
          and servers for correct operation. You should consider enabling chronyd.
    
    Be sure to back up the CA certificates stored in /root/cacert.p12
    These files are required to create replicas. The password for these
    files is the Directory Manager password
    The ipa-server-install command was successful
    FreeIPA server does not run DNS server, skipping update-self-ip-address.
    Created symlink /etc/systemd/system/container-ipa.target.wants/ipa-server-
    update-self-ip-address.service → /usr/lib/systemd/system/ipa-server-update-
    self-ip-address.service.
    Created symlink /etc/systemd/system/container-ipa.target.wants/ipa-server-
    upgrade.service → /usr/lib/systemd/system/ipa-server-upgrade.service.
    Removed /etc/systemd/system/container-ipa.target.wants/ipa-server-configure-
    first.service.
    [  OK  ] Finished Configure IPA server upon the first start.
    FreeIPA server configured.
    
  11. Now you should be able to reach out the web interface by:

    xdg-open "https://$(oc get route idm-sample -o jsonpath='{.spec.host}')"
  12. Look at your objects by: kubectl get all,idm,pvc,secrets

  13. And clean-up the cluster by:

    make undeploy
    oc delete -f config/rbac/scc.yaml

Executing tests

  • For the unit tests run:

    make test
  • For the integration tests with scorecard run:

    # Generate bundle directory
    # bundle.Dockerfile is generated on this step
    # More information about the LABELS inside here:
    # https://github.com/operator-framework/operator-registry/blob/master/docs/design/operator-bundle.md#bundle-annotations
    # https://olm.operatorframework.io/docs/tasks/creating-operator-bundle/#contents-of-annotationsyaml-and-the-dockerfile
    make bundle
    # Running scorecard tests generated in the bundle directory by
    make scorecard-bundle

Deploying with OLM

Pre-requisites:

  • A proper private.mk file setup. (see private.mk.example).
  • The freeipa SecurityContextConstraint created (oc create -f config/rbac/scc.yaml).

Steps:

  1. Create the Security Context Constraint profile (if not yet):

    oc create -f config/rbac/scc.yaml
  2. Create a namespace:

    oc new-project ipa
  3. Build and publish container images:

    make docker-build docker-push \
         bundle bundle-build bundle-push \
         catalog-build catalog-push
  4. Install operator with OLM in the current namespace by:

    make bundle-install
  5. Create a sample idm resource:

    oc create -f config/samples/persistent-storage.yaml
  6. Delete the custom resource created:

    oc delete -f config/samples/persistent-storage.yaml

    TODO You will need to delete the PVC by hand if a new IDM resource have to be created with different options.

  7. Cleanup the operator from the cluster:

    make bundle-uninstall
  8. Remove the namespace:

    oc delete project ipa
  9. Remove the Security Context Constraint profile by:

    oc delete -f config/rbac/scc.yaml

See also: Operator SDK 1.0.0 - Quick Start.

freeipa-operator's People

Contributors

avisiedo avatar frasertweedale avatar vashirov 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  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freeipa-operator's Issues

How to use the feeipa-operator on a managed kubernetes cluster

Dear team,
Firstly thanks for your amazing works.
I am looking for a solution to get freeipa inside a kubernetes cluster, and it seems that your works fit our needs.

So, After a look to the Readme, ./devel/install-local-tools.sh and the makefile, it seems that the operator is designed to works with an OpenShift server.

So here my question is it possible to use this operator on a managed (by a cloud provider) kubernetes cluster ?
Thanks for your help.

Ideally a StatefulSets + Operators guide would be awesome.

I wish you a great day.

Jonathan

Tests are failing in OpenShift CI

https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/openshift_release/13471/rehearse-13471-pull-ci-freeipa-freeipa-operator-master-unit/1329040777505935360

Running Suite: Controller Suite
===============================
Random Seed: 1605703216
Will run 0 of 0 specs
STEP: bootstrapping test environment
2020-11-18T12:40:16.800Z	DEBUG	controller-runtime.test-env	starting control plane	{"api server flags": []}
2020-11-18T12:40:16.805Z	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 0, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
github.com/go-logr/zapr.(*zapLogger).Error
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/go-logr/zapr/zapr.go:128
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:279
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:241
github.com/freeipa/freeipa-operator/controllers.glob..func1
	/go/src/github.com/freeipa/freeipa-operator/controllers/suite_test.go:61
reflect.Value.call
	/usr/local/go/src/reflect/value.go:475
reflect.Value.Call
	/usr/local/go/src/reflect/value.go:336
github.com/onsi/ginkgo/internal/leafnodes.newRunner.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:49
github.com/onsi/ginkgo/internal/leafnodes.(*runner).runAsync.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:86
2020-11-18T12:40:16.805Z	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 1, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
github.com/go-logr/zapr.(*zapLogger).Error
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/go-logr/zapr/zapr.go:128
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:279
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:241
github.com/freeipa/freeipa-operator/controllers.glob..func1
	/go/src/github.com/freeipa/freeipa-operator/controllers/suite_test.go:61
reflect.Value.call
	/usr/local/go/src/reflect/value.go:475
reflect.Value.Call
	/usr/local/go/src/reflect/value.go:336
github.com/onsi/ginkgo/internal/leafnodes.newRunner.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:49
github.com/onsi/ginkgo/internal/leafnodes.(*runner).runAsync.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:86
2020-11-18T12:40:16.805Z	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 2, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
github.com/go-logr/zapr.(*zapLogger).Error
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/go-logr/zapr/zapr.go:128
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:279
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:241
github.com/freeipa/freeipa-operator/controllers.glob..func1
	/go/src/github.com/freeipa/freeipa-operator/controllers/suite_test.go:61
reflect.Value.call
	/usr/local/go/src/reflect/value.go:475
reflect.Value.Call
	/usr/local/go/src/reflect/value.go:336
github.com/onsi/ginkgo/internal/leafnodes.newRunner.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:49
github.com/onsi/ginkgo/internal/leafnodes.(*runner).runAsync.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:86
2020-11-18T12:40:16.806Z	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 3, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
github.com/go-logr/zapr.(*zapLogger).Error
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/go-logr/zapr/zapr.go:128
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:279
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:241
github.com/freeipa/freeipa-operator/controllers.glob..func1
	/go/src/github.com/freeipa/freeipa-operator/controllers/suite_test.go:61
reflect.Value.call
	/usr/local/go/src/reflect/value.go:475
reflect.Value.Call
	/usr/local/go/src/reflect/value.go:336
github.com/onsi/ginkgo/internal/leafnodes.newRunner.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:49
github.com/onsi/ginkgo/internal/leafnodes.(*runner).runAsync.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:86
2020-11-18T12:40:16.807Z	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 4, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
github.com/go-logr/zapr.(*zapLogger).Error
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/go-logr/zapr/zapr.go:128
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:279
sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
	/go/src/github.com/freeipa/freeipa-operator/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:241
github.com/freeipa/freeipa-operator/controllers.glob..func1
	/go/src/github.com/freeipa/freeipa-operator/controllers/suite_test.go:61
reflect.Value.call
	/usr/local/go/src/reflect/value.go:475
reflect.Value.Call
	/usr/local/go/src/reflect/value.go:336
github.com/onsi/ginkgo/internal/leafnodes.newRunner.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:49
github.com/onsi/ginkgo/internal/leafnodes.(*runner).runAsync.func1
	/go/src/github.com/freeipa/freeipa-operator/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go:86
Failure [0.007 seconds]
[BeforeSuite] BeforeSuite 
/go/src/github.com/freeipa/freeipa-operator/controllers/suite_test.go:52
  Unexpected error:
      
      <*fmt.wrapError | 0xc0003e0c00>: {
          msg: "failed to start the controlplane. retried 5 times: fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory",
          err: {
              Op: "fork/exec",
              Path: "/usr/local/kubebuilder/bin/etcd",
              Err: 0x2,
          },
      }
      failed to start the controlplane. retried 5 times: fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory
  occurred
  /go/src/github.com/freeipa/freeipa-operator/controllers/suite_test.go:62
------------------------------
Ran 0 of 0 Specs in 0.007 seconds
FAIL! -- 0 Passed | 0 Failed | 0 Pending | 0 Skipped
--- FAIL: TestAPIs (0.01s)
FAIL
coverage: 0.0% of statements
FAIL	github.com/freeipa/freeipa-operator/controllers	0.028s
FAIL
make: *** [test] Error 1
2020/11/18 12:40:17 Container test in pod unit failed, exit code 2, reason Error
2020/11/18 12:40:17 No custom metadata found and prow metadata already exists. Not updating the metadata.
2020/11/18 12:40:17 Ran for 3m45s
error: some steps failed:
  * could not run steps: step unit failed: test "unit" failed: the pod ci-op-2zmbpxqx/unit failed after 1m3s (failed containers: test): ContainerFailed one or more containers exited
Container test exited with code 2, reason Error

Apparently test target in Makefile generated by operator-sdk doesn't have all the required steps, see operator-framework/operator-sdk#3692

Running the "make cert-manager-self-signed-issuer-create" in step 7 fails

Part of step 7 in the "Quick Start" says:
When the cert-manager operator is installed, run this:
make cert-manager-self-signed-issuer-create

[dthursto@fedora ~]$ make cert-manager-self-signed-issuer-create
make: *** No rule to make target 'cert-manager-self-signed-issuer-create'. Stop.

Looking in mk/cert-manager.mk there is no .PHONY entry for "cert-manager-self-signed-issuer-create". I'm wondering what I'm doing wrong or if there should be an entry for that?

Add vendor directory

OpenShift CI doesn't allow internet access during tests, and our make tests fails since it tries to fetch dependencies over network.

In addition to that, Golang 1.15 made -mod=vendor as the default flag. So I think it makes sense to add /vendor.

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.