Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to parse java web project, yaml template of k8s

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Today, I will talk to you about how to analyze the java web project, the yaml template of K8s, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

ApiVersion: apps/v1kind: Deploymentmetadata: name: projectname-deploymentspec: replicas: 1 # Update: after the container is ready, the delay is 60 seconds. When you cooperate with strategy.maxUnavailable: 0, you can ignore # minReadySeconds: 60 # 600s later, label it and do nothing. It must be greater than minReadySeconds### # progressDeadlineSeconds: 600 strategy: # upgrade method Default method # type: RollingUpdate # strict control, one pod at a time The unavailable status is 0 pod### rollingUpdate: # 1 pod### maxSurge: 1 # the maximum number of unavailable pod allowed for rolling upgrade # maxUnavailable: 0 selector: matchLabels: app: projectname template: metadata: annotations: # modify the value For deployment automatic update # springrain.k8s.version: updateversion # # disable automatic istio injection sidecar### # sidecar.istio.io/inject: "false" labels: app: projectname version: v1 spec: containers:-name: projectname image: 10.98.239.102:5000/projectname:randomversion # Image: projectname:randomversion # set the cpu and memory that can be used by tomcat # resources: limits: cpu: "1" memory: 2Gi requests: cpu: "0.5" memory: 1Gi # set tomcat port # ports:- ContainerPort: 8080 # imagePullPolicy: IfNotPresent env:-name: JAVA_OPTS # do not set the two parameters-XX:+UnlockExperimentalVMOptions-XX:+UseCGroupMemoryLimitForHeap above JDK8 # value: "- Dfile.encoding=utf-8-Dsun.jnu.encoding=utf-8-Djava.security.egd=file:/dev/./urandom" # value: "- Xms1000m-Xmx2000m -Dfile.encoding=utf-8-Dsun.jnu.encoding=utf-8-Djava.security.egd=file:/dev/./urandom-XX:+UnlockExperimentalVMOptions-XX:+UseCGroupMemoryLimitForHeap "# set time zone #-name: TZ value: Asia/Shanghai # set code #-name: LC_ALL value: C .utf-8-name: LANG value: C.UTF-8 # Health check begins # kubernetes believes that the pod is alive If you do not survive, you need to restart # livenessProbe: httpGet: # HTTP status code is between 200and 399 It is considered that the container is running normally # path: projectliveurl port: 8080 scheme: HTTP # initialDelaySeconds: 120 # how many seconds do you need to wait for the first time to perform detection after the container is started? # timeoutSeconds: 5 # probe timeout. Default 1 second, minimum 1 second # successThreshold: 1 # after a failed probe, the minimum number of consecutive successful probes will be considered successful. The default is 1. For liveness, it must be 1. The minimum value is 1. Failure # failureThreshold: after a successful probe, the minimum number of consecutive probe failures is considered a failure. The default is 3. The minimum is 1. Frequency of probing # periodSeconds: 10 #. The default is 10 seconds, and the minimum is 1 second. # you can also use this method # exec: execute the command to monitor if the exit code is not 0 The container is considered to be normal # command: #-cat #-/ tmp/health # can also be used in this way # tcpSocket: / / check health through tcpSocket # port: number # kubernetes considers the pod to be started successfully # ReadinessProbe: httpGet: path: projectliveurl port: 8080 scheme: HTTP initialDelaySeconds: 100 # how many seconds do you need to wait for probing for the first time after the container starts? # timeoutSeconds: 5 # probing timeout. Default 1 second, minimum 1 second # successThreshold: 1 # after a failed probe, the minimum number of consecutive successful probes will be considered successful. The default is 1. For liveness, it must be 1. The minimum value is 1. Failure # failureThreshold: after a successful probe, the minimum number of consecutive probe failures is considered a failure. The default is 3. The minimum is 1. Frequency of probing # periodSeconds: 10 #. The default is 10 seconds. Minimum 1 second. # Health check ends # volumeMounts: # mount point #-mountPath: / usr/local/tomcat/logs # corresponding to the name of the following volume cephfs-pvc-pod # # name: tomcat-pvc # specify a subdirectory Create a subfolder in cephfs # subPath: data/dev/tomcat/projectname/logs # apply the uploaded upload folder #-mountPath: / usr/local/tomcat/webapps/projectname/upload name: tomcat-pvc # specify a subdirectory A subfolder # subPath: data/dev/tomcat/projectname/upload # will be created in cephfs to mount server.xml using configMap, with only one file mounted You need to use subPath### #-mountPath: / usr/local/tomcat/conf/server.xml # name: serverxml-cm # and the following volumes.tomcat-configmap path to correspond to # subPath: serverxmlsubpath-mountPath: / usr/local/tomcat/conf name: tomcat-pvc # and the following volumes.tomcat-configmap Path should correspond to # subPath: basesoft/tomcat-k8s/conf volumes: # Volume name Corresponding to the above mount name # #-name: tomcat-pvc persistentVolumeClaim: # metadata.name### claimName corresponding to cephfs-pvc.yaml: k8s-pvc #-name: serverxml-cm # configMap: # Associated configMap### # name: tomcat-configmap # items: #-key: server.xml # path: serverxmlsubpath---### create projectname service # apiVersion: v1kind: Servicemetadata: name: projectname labels: app: projectnamespec: ports:-port: 8080 targetPort: 8080 nodePort: projectport # Port of node For developers to directly access # protocol: http # "SCTP", "TCP", "UDP" # name: http # use NodePort instead of fixed virtual IP### # clusterIP: 10.98.239.104 selector: app: projectname # Node type is NodePort### type: NodePort Do you have any further understanding of how to parse the java web project and the yaml template for K8s? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report