Skip to content

Commit

Permalink
Merge pull request #137 from francescotimperi/apisix
Browse files Browse the repository at this point in the history
  • Loading branch information
francescotimperi committed Jan 13, 2024
2 parents abf51f2 + f33a12e commit c4a9fcd
Show file tree
Hide file tree
Showing 12 changed files with 713 additions and 3 deletions.
31 changes: 31 additions & 0 deletions deploy/apisix-etcd/etcd-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: apisix-etcd
namespace: nuvolaris
labels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
spec:
minAvailable: 51%
selector:
matchLabels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
32 changes: 32 additions & 0 deletions deploy/apisix-etcd/etcd-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: etcd-apisix-pv-claim
namespace: nuvolaris
labels:
app: etcd-apisix-pv-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: standard
resources:
requests:
storage: 8Gi
28 changes: 28 additions & 0 deletions deploy/apisix-etcd/etcd-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
apiVersion: v1
kind: Secret
metadata:
name: apisix-etcd-jwt-token
namespace: nuvolaris
labels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
type: Opaque
data:
jwt-token.pem: "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlKS1FJQkFBS0NBZ0VBdXlNcjdmOUJWajJ2RjhNUC8zNStrcnA0MlF0Nk5YMmEvS3IyY24xNjBSajBuZ0lvCk1qL1RmdXVnMmJnaHlEdnhDdytKZU1QUUNYMXRGZENzM2RHZ0xmSFppM0MyR21VV250VG1WQTRCSENZdmc4RisKRnBYQURjdE5EKzRWc1F4OUVsN1pKR0lxWFkySThFM3JPWkd4SnhxQmR1bDIwVy9xczNSNFFRMlFsbzU0dzNhagpmVWZCQ3FoeTdveXJWclN5NFgwN0JYL09CYkRCU2NBNUJlTG9ZOFdTNWwvYWFvZnRiVlpqYmxHYkE5S0tvclFNCmN6QjNxenBzQXZyUjZkWVBES1dFMVpGQ1huWjBBdjBsQlZMckk4S1ZkREFaWHBRelFEUDl5dytCMWpaelhiaG0KRGg5UmN6YUt3dXJ5UTA4d0JVanpUU09ydkdaY254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MUpmUDZ4aHpPUTFuUFZVa3d2cGFHNTFOc1lWYmVxRk1wRzF3SW16Skl1a2hXVUlJKzhYClcrK3lWV3ZVSzN2WTJVdjRBbWlVbkFVdHdoNEdLQmtoQW9JQkFRQ2gzeHk3Uk50QjUzREVUYndJbUtlUUxscGgKTXQzNWZLdWdwRTFDb1Y5WTNVZEpaczdlQ1YyN2pzcEFHZ3VxKytzODg1MEw4L3RuVGd5SHZWbVBlSzZGdW5GTgpEak9uNUNHOHByYVNmTVAvNTZjN282R29aRk1NUUtoZDBzOFczODN0Q2Jobk9YQng1S1FOa2hMNWQ2TlZrQzB2Cnd2WGpMUmdud2IxNlJnaGhESUQwVFhYNHc1UXlMVGVkTEYwZnc5Z0ZPeHY4VFhteWVzOGNVdzh5a3RnUEhMYTAKM1dFbzR1U1N4eE9zQTB4QzZ2dTZZM3VybWtVWTluYWpGUDcwaUtMT1dBWkozVkFQeTUxS2kzU2xNRHBRRmpCTgpmcXg2aXFvUGU2L0ZKc29xcHVoN29UNXEyRzhkMWdWa3h1ak1MQXZ5Z2pHQ2JtczVVV3ZFNS9TQ2hvMU0KLS0tLS1FTkQgUlNBIFBSSVZBVEUgS0VZLS0tLS0K"
160 changes: 160 additions & 0 deletions deploy/apisix-etcd/etcd-sts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: apisix-etcd
namespace: nuvolaris
labels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
serviceName: apisix-etcd-headless
podManagementPolicy: Parallel
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
spec:
affinity:
podAffinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
topologyKey: kubernetes.io/hostname
weight: 1
nodeAffinity:
securityContext:
fsGroup: 1001
serviceAccountName: "default"
containers:
- name: etcd
image: docker.io/bitnami/etcd:3.5.7-debian-11-r14
imagePullPolicy: "IfNotPresent"
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 1001
env:
- name: BITNAMI_DEBUG
value: "false"
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_STS_NAME
value: "apisix-etcd"
- name: ETCDCTL_API
value: "3"
- name: ETCD_ON_K8S
value: "yes"
- name: ETCD_START_FROM_SNAPSHOT
value: "no"
- name: ETCD_DISASTER_RECOVERY
value: "no"
- name: ETCD_NAME
value: "$(MY_POD_NAME)"
- name: ETCD_DATA_DIR
value: "/bitnami/etcd/data"
- name: ETCD_LOG_LEVEL
value: "info"
- name: ALLOW_NONE_AUTHENTICATION
value: "yes"
- name: ETCD_AUTH_TOKEN
value: "jwt,priv-key=/opt/bitnami/etcd/certs/token/jwt-token.pem,sign-method=RS256,ttl=10m"
- name: ETCD_ADVERTISE_CLIENT_URLS
value: "http://$(MY_POD_NAME).apisix-etcd-headless.nuvolaris.svc.cluster.local:2379,http://apisix-etcd.nuvolaris.svc.cluster.local:2379"
- name: ETCD_LISTEN_CLIENT_URLS
value: "http://0.0.0.0:2379"
- name: ETCD_INITIAL_ADVERTISE_PEER_URLS
value: "http://$(MY_POD_NAME).apisix-etcd-headless.nuvolaris.svc.cluster.local:2380"
- name: ETCD_LISTEN_PEER_URLS
value: "http://0.0.0.0:2380"
- name: ETCD_INITIAL_CLUSTER_TOKEN
value: "etcd-cluster-k8s"
- name: ETCD_INITIAL_CLUSTER_STATE
value: "new"
- name: ETCD_INITIAL_CLUSTER
value: "apisix-etcd-0=http://apisix-etcd-0.apisix-etcd-headless.nuvolaris.svc.cluster.local:2380"
- name: ETCD_CLUSTER_DOMAIN
value: "apisix-etcd-headless.nuvolaris.svc.cluster.local"
envFrom:
ports:
- name: client
containerPort: 2379
protocol: TCP
- name: peer
containerPort: 2380
protocol: TCP
livenessProbe:
exec:
command:
- /opt/bitnami/scripts/etcd/healthcheck.sh
initialDelaySeconds: 60
periodSeconds: 30
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
readinessProbe:
exec:
command:
- /opt/bitnami/scripts/etcd/healthcheck.sh
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
lifecycle:
preStop:
exec:
command:
- /opt/bitnami/scripts/etcd/prestop.sh
resources:
limits: {}
requests: {}
volumeMounts:
- name: data
mountPath: /bitnami/etcd
- name: etcd-jwt-token
mountPath: /opt/bitnami/etcd/certs/token/
readOnly: true
volumes:
- name: etcd-jwt-token
secret:
secretName: apisix-etcd-jwt-token
defaultMode: 256
- name: data
persistentVolumeClaim:
claimName: etcd-apisix-pv-claim

64 changes: 64 additions & 0 deletions deploy/apisix-etcd/etcd-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
apiVersion: v1
kind: Service
metadata:
name: apisix-etcd
namespace: nuvolaris
labels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
spec:
type: ClusterIP
sessionAffinity: None
ports:
- name: "client"
port: 2379
targetPort: client
- name: "peer"
port: 2380
targetPort: peer
selector:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
timeout: 30 # 30 seconds
---
apiVersion: v1
kind: Service
metadata:
name: apisix-etcd-headless
namespace: nuvolaris
labels:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
ports:
- name: client
port: 2379
targetPort: client
- name: peer
port: 2380
targetPort: peer
selector:
app.kubernetes.io/name: etcd
app.kubernetes.io/instance: apisix
Loading

0 comments on commit c4a9fcd

Please sign in to comment.