You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/09/09 09:49:10 UTC
[GitHub] [apisix-helm-chart] juzhiyuan commented on issue #290: request help: bad member ID arg (strconv.ParseUint: parsing "": invalid syntax), expecting ID in Hex
juzhiyuan commented on issue #290:
URL: https://github.com/apache/apisix-helm-chart/issues/290#issuecomment-1241754762
## Use APISIX Helm chart with standalone deployment etcd
> Thanks to @tao12345666333!
1. Create a namespace apisix
```sh
$ kubectl create ns apisix
namespace/apisix created
```
2. Deploy the etcd instance
```yaml
# etcd-headless.yaml
apiVersion: v1
kind: Service
metadata:
name: etcd-headless
namespace: apisix
labels:
app.kubernetes.io/name: etcd
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
type: ClusterIP
clusterIP: None
ports:
- name: "client"
port: 2379
targetPort: client
- name: "peer"
port: 2380
targetPort: peer
selector:
app.kubernetes.io/name: etcd
---
# etcd.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: etcd
namespace: apisix
labels:
app.kubernetes.io/name: etcd
spec:
selector:
matchLabels:
app.kubernetes.io/name: etcd
serviceName: etcd-headless
podManagementPolicy: Parallel
replicas: 1
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app.kubernetes.io/name: etcd
spec:
securityContext:
fsGroup: 1001
runAsUser: 1001
containers:
- name: etcd
image: docker.io/bitnami/etcd:3.4.20-debian-11-r11
imagePullPolicy: "IfNotPresent"
# command:
# - /scripts/setup.sh
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: ETCDCTL_API
value: "3"
- name: ETCD_NAME
value: "$(MY_POD_NAME)"
- name: ETCD_DATA_DIR
value: /etcd/data
- name: ETCD_ADVERTISE_CLIENT_URLS
value: "http://$(MY_POD_NAME).etcd-headless.apisix.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).etcd-headless.apisix.svc.cluster.local:2380"
- name: ETCD_LISTEN_PEER_URLS
value: "http://0.0.0.0:2380"
- name: ALLOW_NONE_AUTHENTICATION
value: "yes"
ports:
- name: client
containerPort: 2379
- name: peer
containerPort: 2380
volumeMounts:
- name: data
mountPath: /etcd
# If you don't have a storage provisioner or don't want to use persistence volume, you could use an `emptyDir` as follow.
# volumes:
# - name: data
# emptyDir: {}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "8Gi"
```
3. And then apply to kubernetes
```sh
$ kubectl apply -f etcd.yaml
service/etcd-headless created
statefulset.apps/etcd created
```
4. Deploy the APISIX Ingress
> If you don't want to deploy APISIX Ingress, just change --set ingress-controller.enabled=false
```sh
$ helm install apisix apisix/apisix --set gateway.type=NodePort --set ingress-controller.enabled=true --set ingress-controller.config.apisix.serviceNamespace=apisix --namespace apisix --create-namespace --set ingresscontroller.config.apisix.serviceName=apisix-admin --set ingresscontroller.config.ingressPublishService="apisix/apisix-gateway" --set etcd.enabled=false --set etcd.host={"http://etcd-headless.apisix.svc.cluster.local:2379"}
NAME: apisix
LAST DEPLOYED: Fri Sep 9 08:54:57 2022
NAMESPACE: apisix
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
export NODE_PORT=$(kubectl get --namespace apisix -o jsonpath="{.spec.ports[0].nodePort}" services apisix-gateway)
export NODE_IP=$(kubectl get nodes --namespace apisix -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
```
Check pods status
```sh
$ kubectl -n apisix get pods
NAME READY STATUS RESTARTS AGE
apisix-579b99b87d-fhbhh 1/1 Running 0 86s
apisix-ingress-controller-68d44b5d49-b427h 1/1 Running 0 86s
etcd-0 1/1 Running 0 20m
```
5. Verification
```sh
tao@moelove:~$ kubectl create ns apisix-demo
namespace/apisix-demo created
tao@moelove:~$ kubectl -n apisix-demo run httpbin --image kennethreitz/httpbin --port 80
pod/httpbin created
tao@moelove:~$ kubectl -n apisix-demo expose pod httpbin --port 80
service/httpbin exposed
```
Create route YAML (`ar.yaml`):
```yaml
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: httpbin-route
namespace: apisix-demo
spec:
http:
- name: httpbin
match:
hosts:
- local.httpbin.org
paths:
- /*
backends:
- serviceName: httpbin
servicePort: 80
```
```sh
tao@moelove:~$ vim ar.yaml
tao@moelove:~$ kubectl -n apisix-demo apply -f ar.yaml
apisixroute.apisix.apache.org/httpbin-route created
tao@moelove:~$ kubectl get pod,svc,ar
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 38m
tao@moelove:~$ kubectl get pod,svc,ar -n apisix-demo
NAME READY STATUS RESTARTS AGE
pod/httpbin 1/1 Running 0 105s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/httpbin ClusterIP 10.96.229.144 <none> 80/TCP 94s
NAME HOSTS URIS AGE
apisixroute.apisix.apache.org/httpbin-route ["local.httpbin.org"] ["/*"] 20s
```
Try to visit the HTTPBIN service API.
```sh
$ tao@moelove:~$ export NODE_PORT=$(kubectl get --namespace apisix -o jsonpath="{.spec.ports[0].nodePort}" services apisix-gateway)
$ tao@moelove:~$ export NODE_IP=$(kubectl get nodes --namespace apisix -o jsonpath="{.items[0].status.addresses[0].address}")
$ tao@moelove:~$ echo http://$NODE_IP:$NODE_PORT
http://172.18.0.5:32409
$ tao@moelove:~$ curl http://$NODE_IP:$NODE_PORT/anything -H "HOST: local.httpbin.org"
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Host": "local.httpbin.org",
"User-Agent": "curl/7.58.0",
"X-Forwarded-Host": "local.httpbin.org"
},
"json": null,
"method": "GET",
"origin": "172.18.0.5",
"url": "http://local.httpbin.org/anything"
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org