|
| 1 | +# Flags for our UI |
| 2 | +apiVersion: core.openfeature.dev/v1beta1 |
| 3 | +kind: FeatureFlag |
| 4 | +metadata: |
| 5 | + name: ui-flags |
| 6 | + labels: |
| 7 | + app: toggle-shop |
| 8 | +spec: |
| 9 | + flagSpec: |
| 10 | + flags: |
| 11 | + offer-free-shipping: |
| 12 | + state: ENABLED |
| 13 | + variants: |
| 14 | + 'on': true |
| 15 | + 'off': false |
| 16 | + defaultVariant: 'on' |
| 17 | +--- |
| 18 | +# Flags for our backend application |
| 19 | +apiVersion: core.openfeature.dev/v1beta1 |
| 20 | +kind: FeatureFlag |
| 21 | +metadata: |
| 22 | + name: app-flags |
| 23 | + labels: |
| 24 | + app: toggle-shop |
| 25 | +spec: |
| 26 | + flagSpec: |
| 27 | + flags: |
| 28 | + use-distributed-db: |
| 29 | + state: ENABLED |
| 30 | + variants: |
| 31 | + 'on': true |
| 32 | + 'off': false |
| 33 | + defaultVariant: 'off' |
| 34 | + use-secure-protocol: |
| 35 | + state: ENABLED |
| 36 | + variants: |
| 37 | + 'on': true |
| 38 | + 'off': false |
| 39 | + defaultVariant: 'off' |
| 40 | +--- |
| 41 | +# Feature flag source custom resource, configuring flagd to source flags from FeatureFlag CRDs |
| 42 | +apiVersion: core.openfeature.dev/v1beta1 |
| 43 | +kind: FeatureFlagSource |
| 44 | +metadata: |
| 45 | + name: ui-flag-source |
| 46 | + labels: |
| 47 | + app: toggle-shop |
| 48 | +spec: |
| 49 | + sources: |
| 50 | + - source: ui-flags |
| 51 | + provider: kubernetes |
| 52 | +--- |
| 53 | +# Feature flag source custom resource, configuring flagd to source flags from FeatureFlag CRDs |
| 54 | +apiVersion: core.openfeature.dev/v1beta1 |
| 55 | +kind: FeatureFlagSource |
| 56 | +metadata: |
| 57 | + name: app-flag-source |
| 58 | + labels: |
| 59 | + app: toggle-shop |
| 60 | +spec: |
| 61 | + sources: |
| 62 | + - source: app-flags |
| 63 | + provider: kubernetes |
| 64 | +--- |
| 65 | +# Standalone flagd for serving UI |
| 66 | +apiVersion: core.openfeature.dev/v1beta1 |
| 67 | +kind: Flagd |
| 68 | +metadata: |
| 69 | + name: flagd-ui |
| 70 | +spec: |
| 71 | + replicas: 1 |
| 72 | + serviceAccountName: default |
| 73 | + featureFlagSource: ui-flag-source |
| 74 | + ingress: |
| 75 | + enabled: true |
| 76 | + annotations: |
| 77 | + nginx.ingress.kubernetes.io/use-regex: 'true' |
| 78 | + nginx.ingress.kubernetes.io/rewrite-target: /ofrep/$1 |
| 79 | + nginx.ingress.kubernetes.io/force-ssl-redirect: 'false' |
| 80 | + hosts: |
| 81 | + - localhost |
| 82 | + - '' |
| 83 | + ingressClassName: nginx |
| 84 | + pathType: ImplementationSpecific |
| 85 | + ofrepPath: /api/ofrep/(.*) |
| 86 | +--- |
| 87 | +# Standalone flagd for serving in-process provider |
| 88 | +apiVersion: core.openfeature.dev/v1beta1 |
| 89 | +kind: Flagd |
| 90 | +metadata: |
| 91 | + name: flagd-in-process |
| 92 | +spec: |
| 93 | + replicas: 1 |
| 94 | + serviceType: ClusterIP |
| 95 | + serviceAccountName: default |
| 96 | + featureFlagSource: app-flag-source |
| 97 | +--- |
| 98 | +# In-process provider configuration |
| 99 | +apiVersion: core.openfeature.dev/v1beta1 |
| 100 | +kind: InProcessConfiguration |
| 101 | +metadata: |
| 102 | + name: in-process-config |
| 103 | +spec: |
| 104 | + host: flagd-in-process |
| 105 | +--- |
| 106 | +# Deployment of a demo-app using our custom resources |
| 107 | +apiVersion: apps/v1 |
| 108 | +kind: Deployment |
| 109 | +metadata: |
| 110 | + name: toggle-shop-deployment |
| 111 | + labels: |
| 112 | + app: toggle-shop |
| 113 | +spec: |
| 114 | + replicas: 1 |
| 115 | + selector: |
| 116 | + matchLabels: |
| 117 | + app: toggle-shop |
| 118 | + template: |
| 119 | + metadata: |
| 120 | + labels: |
| 121 | + app: toggle-shop |
| 122 | + annotations: |
| 123 | + openfeature.dev/enabled: 'true' |
| 124 | + openfeature.dev/inprocessconfiguration: 'in-process-config' |
| 125 | + spec: |
| 126 | + containers: |
| 127 | + - name: toggle-shop |
| 128 | + image: ghcr.io/open-feature/toggle-shop:main # x-release-please-version |
| 129 | + ports: |
| 130 | + - containerPort: 3000 |
| 131 | + name: demo-port |
| 132 | + env: |
| 133 | + - name: FLAGD_HOST |
| 134 | + value: flagd-in-process |
| 135 | +--- |
| 136 | +# Service to expose our application |
| 137 | +apiVersion: v1 |
| 138 | +kind: Service |
| 139 | +metadata: |
| 140 | + name: toggle-shop-app-service |
| 141 | + labels: |
| 142 | + app: toggle-shop |
| 143 | +spec: |
| 144 | + type: NodePort |
| 145 | + selector: |
| 146 | + app: toggle-shop |
| 147 | + ports: |
| 148 | + - port: 3000 |
| 149 | + targetPort: demo-port |
| 150 | + nodePort: 30000 |
| 151 | +--- |
| 152 | +# Ingress for our application |
| 153 | +apiVersion: networking.k8s.io/v1 |
| 154 | +kind: Ingress |
| 155 | +metadata: |
| 156 | + name: toggle-shop-ingress |
| 157 | +spec: |
| 158 | + ingressClassName: nginx |
| 159 | + rules: |
| 160 | + - host: localhost |
| 161 | + http: |
| 162 | + paths: |
| 163 | + - pathType: Prefix |
| 164 | + path: / |
| 165 | + backend: |
| 166 | + service: |
| 167 | + name: toggle-shop-app-service |
| 168 | + port: |
| 169 | + number: 3000 |
0 commit comments