我有一个使用容器docker的springboot应用程序,它的工作原理是,但是现在我想在kubernetes集群中运行。 我将这个容器推入dockerhub并工作了
我创建2个文件
我正在使用本教程https://learnk8s.io/blog/scaling-spring-boot-microservices/,但没有minikube,我的公司中有3台服务器
[webapp@srvapih controle-acesso-api]$ ll
total 8
-rw-rw-r--. 1 webapp webapp 433 Abr 25 08:19 cta-deployment.yaml
-rw-rw-r--. 1 webapp webapp 163 Abr 25 08:18 cta-service.ymal
cta-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: controle-acesso-api
spec:
replicas: 1
template:
metadata:
labels:
app: controle-acesso-api
spec:
containers:
- name: api
image: xxxx/controleacesso-api
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
resources:
limits:
memory: 128Mi
cta-service.ymal
apiVersion: v1
kind: Service
metadata:
name: controle-acesso-api
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: controle-acesso-api
我执行此命令
[webapp@srvapih controle-acesso-api]$ kubectl create -f cta-deployment.yaml
deployment.extensions/controle-acesso-api created
[webapp@srvapih controle-acesso-api]$ kubectl create -f cta-service.ymal
service/controle-acesso-api created
[webapp@srvapih controle-acesso-api]$ kubectl get pods -l=app=controle-acesso-api
NAME READY STATUS RESTARTS AGE
controle-acesso-api-5898c87db6-bxks9 0/1 Pending 0 20s
[webapp@srvapih controle-acesso-api]$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/controle-acesso-api-5898c87db6-bxks9 0/1 Pending 0 2m50s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/controle-acesso-api ClusterIP 10.100.155.84 <none> 8080/TCP 2m42s
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 6d17h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/controle-acesso-api 0/1 1 0 2m50s
NAME DESIRED CURRENT READY AGE
replicaset.apps/controle-acesso-api-5898c87db6 1 1 0 2m50s
描述豆荚
[webapp@srvapih controle-acesso-api]$ kubectl describe pods controle-acesso-api-5898c87db6-bxks9
Name: controle-acesso-api-5898c87db6-bxks9
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: <none>
Labels: app=controle-acesso-api
pod-template-hash=5898c87db6
Annotations: <none>
Status: Pending
IP:
Controlled By: ReplicaSet/controle-acesso-api-5898c87db6
Containers:
api:
Image: beirario/controle-acesso-api
Port: 8080/TCP
Host Port: 0/TCP
Limits:
memory: 128Mi
Requests:
memory: 128Mi
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-xdqpp (ro)
Conditions:
Type Status
PodScheduled False
Volumes:
default-token-xdqpp:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-xdqpp
Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 95s (x27 over 14m) default-scheduler 0/3 nodes are available: 3 node(s) had taints that the pod didn't tolerate.
很奇怪,因为我的节点处于未就绪状态
[webapp@srvapih controle-acesso-api]$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
srvapi2h.intranet NotReady <none> 6d17h v1.13.4
srvapi3h.intranet NotReady <none> 6d17h v1.13.4
srvapih.intranet NotReady master 6d17h v1.13.4