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

enable https access #48

Merged
merged 4 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ spec:
"raw_body": postdata,
"timeout": "2500ms",
"raise_error": false,
"tls_insecure_skip_verify": true
"tls_ca_cert": REPLACE_WITH_CA_CERT
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ spec:
"raw_body": postdata,
"timeout": "2500ms",
"raise_error": false,
"tls_insecure_skip_verify": true
"tls_ca_cert": REPLACE_WITH_CA_CERT
})
}

Expand Down
16 changes: 16 additions & 0 deletions integrity-shield-operator/controllers/integrityshield.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"reflect"
"strings"
"time"

apiv1 "github.com/open-cluster-management/integrity-shield/integrity-shield-operator/api/v1"
Expand Down Expand Up @@ -1103,6 +1104,21 @@ func (r *IntegrityShieldReconciler) createOrUpdateConstraintTemplate(instance *a

if err != nil && errors.IsNotFound(err) {
reqLogger.Info("Creating a new resource")
// load ca cert
secret := &corev1.Secret{}
err = r.Get(ctx, types.NamespacedName{Name: instance.Spec.APITlsSecretName, Namespace: instance.Namespace}, secret)
if err != nil {
reqLogger.Error(err, "Fail to load CA Cert from Secret")
}
cabundle, ok := secret.Data["ca.crt"]
rego := expected.Spec.Targets[0].Rego
if ok {
ca_str := fmt.Sprintf("%#v\n", string(cabundle))
rego = strings.Replace(rego, "REPLACE_WITH_CA_CERT", ca_str, 1)

}
expected.Spec.Targets[0].Rego = rego

err = r.Create(ctx, expected)
if err != nil && errors.IsAlreadyExists(err) {
// Already exists from previous reconcile, requeue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ spec:
parameters:
constraintName: configmap-constraint
action:
admissionControl:
enforce: false
audit:
inform: true
mode: detect
objectSelector:
- name: sample-cm
signers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ spec:
parameters:
constraintName: deployment-constraint
action:
admissionControl:
enforce: false
audit:
inform: true
mode: detect
objectSelector:
- name: sample-deploy
signers:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This is an example of constraint template.
# This constraint template is installed by Integrity Shield Operator.
apiVersion: templates.gatekeeper.sh/v1beta1
kind: ConstraintTemplate
metadata:
Expand Down Expand Up @@ -40,7 +42,8 @@ spec:
"raw_body": postdata,
"timeout": "2500ms",
"raise_error": false,
"tls_insecure_skip_verify": true
"tls_ca_cert": "-----BEGIN CERTIFICATE-----\nMIIDITCCAgmgA.......\n-----END CERTIFICATE-----"

})
}

Expand Down