Skip to content

Commit ebf4256

Browse files
authored
Fix/issuer name (#8)
* improved getting started steps * fixed self signed issuer reference
1 parent 314ace6 commit ebf4256

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

config/manager/manager.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ spec:
6262
apiVersion: cert-manager.io/v1
6363
kind: Issuer
6464
metadata:
65-
name: selfsigned-issuer
65+
name: open-feature-operator-selfsigned-issuer
6666
namespace: open-feature-operator-system
6767
spec:
6868
selfSigned: {}
@@ -78,4 +78,4 @@ spec:
7878
- open-feature-operator-webhook-service.open-feature-operator-system.svc
7979
- open-feature-operator-webhook-service.open-feature-operator-system.svc.cluster.local
8080
issuerRef:
81-
name: selfsigned-issuer
81+
name: open-feature-operator-selfsigned-issuer

examples/deployment.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nginx-deployment
5+
annotations:
6+
openfeature.dev: "enabled"
7+
openfeature.dev/featureflagconfiguration: "featureflagconfiguration-sample"
8+
spec:
9+
selector:
10+
matchLabels:
11+
app: nginx
12+
replicas: 2 # tells deployment to run 2 pods matching the template
13+
template:
14+
metadata:
15+
labels:
16+
app: nginx
17+
spec:
18+
containers:
19+
- name: nginx
20+
image: nginx:1.14.2
21+
ports:
22+
- containerPort: 80

issuer

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Issuer
3+
metadata:
4+
name: selfsigned-issuer
5+
namespace: open-feature-operator-system
6+
spec:
7+
selfSigned: {}

webhooks/mutating_admission_webhook.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type PodMutator struct {
2828

2929
// PodMutator adds an annotation to every incoming pods.
3030
func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admission.Response {
31+
3132
pod := &corev1.Pod{}
3233
m.Log.V(2).Info("Handling pod %s/%s", req.Namespace, req.Name)
3334
err := m.decoder.Decode(req, pod)
@@ -60,6 +61,7 @@ func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admissio
6061
}
6162
}
6263

64+
// TODO: this should be a short sha to avoid collisions
6365
configName := fmt.Sprintf("%s-%s-config", pod.Name, pod.Namespace)
6466
// Create the agent configmap
6567
m.Client.Delete(context.TODO(), &corev1.ConfigMap{
@@ -68,7 +70,7 @@ func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admissio
6870
Namespace: req.Namespace,
6971
},
7072
}) // Delete the configmap if it exists
71-
m.Log.V(1).Info("Creating configmap %s/%s", pod.Namespace, configName)
73+
m.Log.V(1).Info(fmt.Sprintf("Creating configmap %s/%s", pod.Namespace, configName))
7274
if err := m.Client.Create(ctx, &corev1.ConfigMap{
7375
ObjectMeta: metav1.ObjectMeta{
7476
Name: configName,
@@ -79,11 +81,11 @@ func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admissio
7981
"config.yaml": featureFlagCustomResource.Spec.FeatureFlagSpec,
8082
},
8183
}); err != nil {
82-
fmt.Printf("failed to create config map %s", configName)
84+
fmt.Printf(fmt.Sprintf("failed to create config map %s", configName))
8385
return admission.Errored(http.StatusInternalServerError, err)
8486
}
8587

86-
m.Log.V(1).Info("Creating sidecar for pod %s/%s", pod.Namespace, pod.Name)
88+
m.Log.V(1).Info(fmt.Sprintf("Creating sidecar for pod %s/%s", pod.Namespace, pod.Name))
8789
// Inject the agent
8890
pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{
8991
Name: "flagd-config",

0 commit comments

Comments
 (0)