NodePort to a Geth pod 在 k8s 上不起作用



我正在尝试在k8s上部署Geth(ethereum/client-go(pod。但我不能错误地部署吊舱";Fatal: Error starting protocol stack: listen tcp: lookup "192.168.1.10": no such host";。

我的deploy.yaml在这里。

---
apiVersion: v1
kind: PersistentVolume
metadata:
name: chaindatastorage
spec:
capacity:
storage: 1000Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-ssd-storage
local:
path: /k8sNodeData/ethDataDir
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: disktype
operator: In
values:
- ssd
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: chaindatavolumeclaim
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 1000Gi
storageClassName: local-ssd-storage
---
apiVersion: v1
kind: Service
metadata:
name: geth-port
spec:
type: NodePort
ports:
- name: geth-sync-port
port: 30303
targetPort: 30303
nodePort: 30303
- name: geth-rpc-port
port: 8545
targetPort: 8545
nodePort: 8545
selector:
name: gethnode
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gethnodedeployment
spec:
replicas: 1
selector:
matchLabels:
name: gethnode
template:
metadata:
labels:
name: gethnode
spec:
containers:
- name: gethnode
image: ethereum/client-go
args:
- "--syncmode=full"
- "--maxpeers=80"
- "--cache=8192"
- "--http"
- "--http.addr="192.168.1.10""
- "--http.port=8545"
volumeMounts:
- name: gethchaindata
mountPath: /root/.ethereum
resources:
limits:
memory: 20480Mi
cpu: 4000m
volumes:
- name: gethchaindata
persistentVolumeClaim:
claimName: chaindatavolumeclaim
---

kubectl get service的结果在这里。

NAME                      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                         AGE
geth-port                 NodePort    10.110.121.244   <none>        30303:30303/TCP,8545:8545/TCP   78s
kubernetes                ClusterIP   10.96.0.1        <none>        443/TCP                         29d

吊舱的kubectl get logs结果如下。

INFO [10-03|09:40:33.482] Starting Geth on Ethereum mainnet... 
INFO [10-03|09:40:33.483] Maximum peer count                       ETH=80 LES=0 total=80
INFO [10-03|09:40:33.483] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
ERROR[10-03|09:40:33.483] Failed to enumerate USB devices          hub=ledger vendor=11415 failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[10-03|09:40:33.483] Failed to enumerate USB devices          hub=trezor vendor=21324 failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[10-03|09:40:33.483] Failed to enumerate USB devices          hub=trezor vendor=4617  failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[10-03|09:40:33.483] Failed to enumerate USB devices          hub=ledger vendor=11415 failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[10-03|09:40:33.483] Failed to enumerate USB devices          hub=trezor vendor=21324 failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[10-03|09:40:33.483] Failed to enumerate USB devices          hub=trezor vendor=4617  failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
INFO [10-03|09:40:33.483] Set global gas cap                       cap=25000000
INFO [10-03|09:40:33.483] Allocated trie memory caches             clean=2.00GiB dirty=2.00GiB
INFO [10-03|09:40:33.483] Allocated cache and file handles         database=/root/.ethereum/geth/chaindata cache=4.00GiB handles=524288
ERROR[10-03|09:40:34.483] Failed to enumerate USB devices          hub=trezor vendor=4617  failcount=3 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[10-03|09:40:34.483] Failed to enumerate USB devices          hub=trezor vendor=21324 failcount=3 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[10-03|09:40:34.483] Failed to enumerate USB devices          hub=ledger vendor=11415 failcount=3 err="failed to initialize libusb: libusb: unknown error [code -99]"
INFO [10-03|09:40:34.769] Opened ancient database                  database=/root/.ethereum/geth/chaindata/ancient
INFO [10-03|09:40:34.825] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000 Petersburg: 7280000 Istanbul: 9069000, Muir Glacier: 9200000, YOLO v1: <nil>, Engine: ethash}"
INFO [10-03|09:40:34.825] Disk storage enabled for ethash caches   dir=/root/.ethereum/geth/ethash count=3
INFO [10-03|09:40:34.825] Disk storage enabled for ethash DAGs     dir=/root/.ethash               count=2
INFO [10-03|09:40:34.826] Initialising Ethereum protocol           versions="[65 64 63]" network=1 dbversion=8
INFO [10-03|09:40:37.518] Loaded most recent local header          number=10974617 hash="d28c04…5fe44a" td=17763879313328271327648 age=1d4h43m
INFO [10-03|09:40:37.519] Loaded most recent local full block      number=10973423 hash="92578b…ae09c1" td=17759925126330650308055 age=1d9h14m
INFO [10-03|09:40:37.519] Loaded most recent local fast block      number=10974617 hash="d28c04…5fe44a" td=17763879313328271327648 age=1d4h43m
INFO [10-03|09:40:37.521] Loaded local transaction journal         transactions=0 dropped=0
INFO [10-03|09:40:37.521] Regenerated local transaction journal    transactions=0 accounts=0
INFO [10-03|09:40:37.522] Starting peer-to-peer node               instance=Geth/v1.9.23-unstable-9d1e2027-20200930/linux-amd64/go1.15.2
INFO [10-03|09:40:37.576] New local node record                    seq=52227 id=78ab8e1d111e4ab5 ip=127.0.0.1 udp=30303 tcp=30303
INFO [10-03|09:40:37.577] Started P2P networking                   self=enode://0b9ee2182b4382638cd77fc8b4369d00b4c14cc6c46d4c71d84a9a9fc191cab75c6566b78a42ddcf4a4d00ba9057747588750f518133bf821cd09e69d769ba0b@127.0.0.1:30303
INFO [10-03|09:40:37.580] IPC endpoint opened                      url=/root/.ethereum/geth.ipc
INFO [10-03|09:40:37.581] IPC endpoint closed                      url=/root/.ethereum/geth.ipc
Fatal: Error starting protocol stack: listen tcp: lookup "192.168.1.10": no such host
Fatal: Error starting protocol stack: listen tcp: lookup "192.168.1.10": no such host

当我关闭- "--http"- "--http.addr="192.168.1.10""- "--http.port=8545"设置时,吊舱工作没有任何问题。吊舱开始同步。CCD_ 8至CCD_。所以我认为NodePort设置的格式是正确的。我想知道为什么只有当我添加了一系列--http设置时,pod才能启动。

我已经更改了k8s的端口范围。所以我认为端口30303和8545没有错。

我想知道在哪里修复它或错误的原因。

10/05
kubectl get pod -A的结果

NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
default       gethnodedeployment-6f5cd5cf4b-wnqst        1/1     Running   1          20s
default       intelnuc-mysql-deployment-9685c849-q6c9j   1/1     Running   0          6d20h
kube-system   coredns-66bff467f8-gbf9r                   1/1     Running   0          30d
kube-system   coredns-66bff467f8-xg72w                   1/1     Running   0          30d
kube-system   etcd-k8smaster                             1/1     Running   0          30d
kube-system   kube-apiserver-k8smaster                   1/1     Running   1          40h
kube-system   kube-controller-manager-k8smaster          1/1     Running   3          30d
kube-system   kube-flannel-ds-amd64-gcg5c                1/1     Running   0          30d
kube-system   kube-flannel-ds-amd64-mn7zq                1/1     Running   0          17d
kube-system   kube-flannel-ds-amd64-p6lkz                1/1     Running   0          30d
kube-system   kube-proxy-ckfkm                           1/1     Running   0          30d
kube-system   kube-proxy-qhnbn                           1/1     Running   0          17d
kube-system   kube-proxy-rr6b8                           1/1     Running   0          30d
kube-system   kube-scheduler-k8smaster                   1/1     Running   3          30d

您的部署缺少一个标签:

apiVersion: apps/v1
kind: Deployment
metadata:
name: gethnodedeployment

需要成为

apiVersion: apps/v1
kind: Deployment
metadata:
name: gethnodedeployment
labels:
name: gethnode

标签是服务选择器用来查找匹配pod的标签。

最新更新