Skip to content

Commit 1c4d268

Browse files
authored
Refactored standalone rules configuration to be editable through helm values and added option to set the rules configuration with an existing configmap. (#717)
1 parent e52d26f commit 1c4d268

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

charts/apisix/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ The command removes all the Kubernetes components associated with the chart and
6868
| apisix.customPlugins.plugins[0].configMap.name | string | `"configmap-name"` | name of configmap. |
6969
| apisix.deployment.mode | string | `"traditional"` | Apache APISIX deployment mode Optional: traditional, decoupled, standalone ref: https://apisix.apache.org/docs/apisix/deployment-modes/ |
7070
| apisix.deployment.role | string | `"traditional"` | Deployment role Optional: traditional, data_plane, control_plane ref: https://apisix.apache.org/docs/apisix/deployment-modes/ |
71+
| apisix.deployment.standalone | object | `{"config":"routes:\n-\n uri: /hi\n upstream:\n nodes:\n \"127.0.0.1:1980\": 1\n type: roundrobin\n","existingConfigMap":""}` | Standalone rules configuration ref: https://apisix.apache.org/docs/apisix/deployment-modes/#standalone |
72+
| apisix.deployment.standalone.config | string | `"routes:\n-\n uri: /hi\n upstream:\n nodes:\n \"127.0.0.1:1980\": 1\n type: roundrobin\n"` | Rules which are set to the default apisix.yaml configmap. If apisix.delpoyment.standalone.existingConfigMap is empty, these are used. |
73+
| apisix.deployment.standalone.existingConfigMap | string | `""` | Specifies the name of the ConfigMap that contains the rule configurations. The configuration must be set to the key named `apisix.yaml` in the configmap. |
7174
| apisix.deployment.role_traditional.config_provider | string | `"etcd"` | |
7275
| apisix.discovery.enabled | bool | `false` | Enable or disable Apache APISIX integration service discovery |
7376
| apisix.discovery.registry | object | `{}` | Service discovery registry. Refer to [configuration under discovery](https://github.com/apache/apisix/blob/master/conf/config.yaml.example#L307) for example. Also see [example of using external service discovery](https://apisix.apache.org/docs/ingress-controller/1.8.0/tutorials/external-service-discovery/). |

charts/apisix/templates/apisix-config-cm.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,13 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
{{- if eq .Values.apisix.deployment.mode "standalone" }}
17+
{{- if and (eq .Values.apisix.deployment.mode "standalone") (not .Values.apisix.deployment.standalone.existingConfigMap) }}
1818
kind: ConfigMap
1919
apiVersion: v1
2020
metadata:
2121
name: apisix.yaml
2222
data:
2323
apisix.yaml: |
24-
routes:
25-
-
26-
uri: /hi
27-
upstream:
28-
nodes:
29-
"127.0.0.1:1980": 1
30-
type: roundrobin
24+
{{- .Values.apisix.deployment.standalone.config | nindent 4 }}
3125
#END
3226
{{- end }}

charts/apisix/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ spec:
253253
volumes:
254254
{{- if eq .Values.apisix.deployment.mode "standalone" }}
255255
- configMap:
256-
name: apisix.yaml
256+
name: {{ .Values.apisix.deployment.standalone.existingConfigMap | default "apisix.yaml" }}
257257
name: apisix-admin
258258
{{- end }}
259259
- configMap:

charts/apisix/values.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,24 @@ apisix:
355355
# enum: etcd, yaml
356356
config_provider: "etcd"
357357

358+
# -- Standalone rules configuration
359+
#
360+
# ref: https://apisix.apache.org/docs/apisix/deployment-modes/#standalone
361+
standalone:
362+
# -- Rules which are set to the default apisix.yaml configmap.
363+
# If apisix.delpoyment.standalone.existingConfigMap is empty, these are used.
364+
config: |
365+
routes:
366+
-
367+
uri: /hi
368+
upstream:
369+
nodes:
370+
"127.0.0.1:1980": 1
371+
type: roundrobin
372+
# -- Specifies the name of the ConfigMap that contains the rule configurations.
373+
# The configuration must be set to the key named `apisix.yaml` in the configmap.
374+
existingConfigMap: ""
375+
358376
admin:
359377
# -- Enable Admin API
360378
enabled: true

0 commit comments

Comments
 (0)