当前位置: 首页 > news >正文

大型网站建设机构保定建设信息网站

大型网站建设机构,保定建设信息网站,手机端企业网站设计,课件ppt模板免费下载网站目录 一.创建helm chart#xff08;以nginx为例#xff09; 1.通过create去创建模板 2.查看模板下的文件 3.用chart模版安装nginx 二.版本更新和回滚问题 1.使用upgrade -f values.yaml或者命令行--set来设置 2.查看历史版本并回滚 三.helm模板内管道和函数 1.defau…目录 一.创建helm chart以nginx为例 1.通过create去创建模板 2.查看模板下的文件 3.用chart模版安装nginx 二.版本更新和回滚问题 1.使用upgrade -f values.yaml或者命令行--set来设置 2.查看历史版本并回滚 三.helm模板内管道和函数 1.defautl 2.quote 3.indent和nindent 4.upper 5.title 6.toYaml 上一篇文章说到我们可以通过helm将众多已经初步配置好的yaml文件下载来整合使用甚至还可以自己定义好需要的安装参数用于下载完成后直接使用而不需要过多更改现在仍然可以在这些功能上继续推进。创建helm chart模板现成的yaml文件自己只需要更改values变量文件即可如下 一.创建helm chart以nginx为例 1.通过create去创建模板 [rootk8s-master helm]# helm create nginx #创建完成后会在本地创建一个nginx目录 drwxr-xr-x 4 root   root         93 Mar 18 19:58 nginx [rootk8s-master helm]# tree nginx nginx ├── charts   #存放的依赖的子chart ├── Chart.yaml     #存放chart基本信息的文件 ├── templates     #模板名称都简单翻译一下就懂存的是什么 │   ├── deployment.yaml │   ├── _helpers.tpl   #模板助手 │   ├── hpa.yaml     │   ├── ingress.yaml │   ├── NOTES.txt   #本chart的帮助信息 │   ├── serviceaccount.yaml │   ├── service.yaml │   └── tests │       └── test-connection.yaml └── values.yaml   #存储的是你在的templates中文件需要用到的变量 ​ 3 directories, 10 files 2.查看模板下的文件 [rootk8s-master helm]# cat nginx/templates/service.yaml apiVersion: v1 kind: Service metadata:name: {{ include nginx.fullname . }}   #这些使用{{}}括起来的变量就是你需要在values.yaml文件中用值替换的变量labels:{{- include nginx.labels . | nindent 4 }} spec:type: {{ .Values.service.type }}ports:- port: {{ .Values.service.port }}targetPort: httpprotocol: TCPname: httpselector:{{- include nginx.selectorLabels . | nindent 4 }} ​ 3.用chart模版安装nginx 1在values.yaml中定义变量如下是nginx模版的原始文件 [rootk8s-master nginx]# cat values.yaml # Default values for nginx. # This is a YAML-formatted file. # Declare variables to be passed into your templates. ​ replicaCount: 1 ​ image:repository: nginx   #找到需要的地方这里是镜像名pullPolicy: IfNotPresent   #镜像拉取策略# Overrides the image tag whose default is the chart appVersion.tag:   #版本信息 ​ imagePullSecrets: [] nameOverride: fullnameOverride: ​ serviceAccount:# Specifies whether a service account should be createdcreate: true# Annotations to add to the service accountannotations: {}# The name of the service account to use.# If not set and create is true, a name is generated using the fullname templatename: ​ podAnnotations: {} ​ podSecurityContext: {}# fsGroup: 2000 ​ securityContext: {}# capabilities:#   drop:#   - ALL# readOnlyRootFilesystem: true# runAsNonRoot: true# runAsUser: 1000 ​ service:   #service类型和端口type: ClusterIPport: 80 ​ ingress:   #ingress的相关配置enabled: falseclassName: annotations: {}# kubernetes.io/ingress.class: nginx# kubernetes.io/tls-acme: truehosts:- host: chart-example.localpaths:- path: /pathType: ImplementationSpecifictls: []# - secretName: chart-example-tls#   hosts:#     - chart-example.local ​ resources: {}   #资源要求# We usually recommend not to specify default resources and to leave this as a conscious# choice for the user. This also increases chances charts run on environments with little# resources, such as Minikube. If you do want to specify resources, uncomment the following# lines, adjust them as necessary, and remove the curly braces after resources:.# limits:#   cpu: 100m#   memory: 128Mi# requests:#   cpu: 100m#   memory: 128Mi ​ autoscaling:enabled: falseminReplicas: 1maxReplicas: 100targetCPUUtilizationPercentage: 80# targetMemoryUtilizationPercentage: 80 ​ nodeSelector: {} ​ tolerations: [] ​ affinity: {} 2配置后的values.yaml [rootk8s-master helm]# cat nginx/values.yaml # Default values for nginx. # This is a YAML-formatted file. # Declare variables to be passed into your templates. ​ replicaCount: 1 ​ image:repository: nginxpullPolicy: IfNotPresent# Overrides the image tag whose default is the chart appVersion.tag: 1.17.3   #版本为1.17.3​ imagePullSecrets: [] nameOverride: fullnameOverride: ​ serviceAccount:# Specifies whether a service account should be createdcreate: true# Annotations to add to the service accountannotations: {}# The name of the service account to use.# If not set and create is true, a name is generated using the fullname templatename: ​ podAnnotations: {} ​ podSecurityContext: {}# fsGroup: 2000 ​ securityContext: {}# capabilities:#   drop:#   - ALL# readOnlyRootFilesystem: true# runAsNonRoot: true# runAsUser: 1000 ​ service:type: NodePort   #NodePort类型port: 80     #80端口 ​ ingress:enabled: falseclassName: annotations: {}# kubernetes.io/ingress.class: nginx# kubernetes.io/tls-acme: truehosts:- host: chart-example.localpaths:- path: /pathType: ImplementationSpecifictls: []# - secretName: chart-example-tls#   hosts:#     - chart-example.local ​ resources: {}# We usually recommend not to specify default resources and to leave this as a conscious# choice for the user. This also increases chances charts run on environments with little# resources, such as Minikube. If you do want to specify resources, uncomment the following# lines, adjust them as necessary, and remove the curly braces after resources:.# limits:#   cpu: 100m#   memory: 128Mi# requests:#   cpu: 100m#   memory: 128Mi ​ autoscaling:enabled: falseminReplicas: 1maxReplicas: 100targetCPUUtilizationPercentage: 80# targetMemoryUtilizationPercentage: 80 ​ nodeSelector: {} ​ tolerations: [] ​ affinity: {} 3安装命令 同k8s运行pod差不多都可以先测试一下但不实际运行helm install --dry-run my-nginx nginx/卸载将install替换为uninstall即可 [rootk8s-master helm]# helm install my-nginx nginx/ #指定好安装后的名称后要指定这个nginx模版目录安装完成后还会提示你访问方式 NAME: my-nginx LAST DEPLOYED: Mon Mar 18 20:27:00 2024 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES: 1. Get the application URL by running these commands:export NODE_PORT$(kubectl get --namespace default -o jsonpath{.spec.ports[0].nodePort} services my-nginx)export NODE_IP$(kubectl get nodes --namespace default -o jsonpath{.items[0].status.addresses[0].address})echo http://$NODE_IP:$NODE_PORT[rootk8s-master helm]# kubectl get pods,svc NAME                           READY   STATUS   RESTARTS   AGE pod/my-nginx-9d774fb48-94wd8   1/1     Running   0         3m29s ​ NAME                 TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)       AGE service/kubernetes   ClusterIP   10.96.0.1       none       443/TCP       90m service/my-nginx     NodePort   10.97.171.192   none       80:30140/TCP   3m29s [rootk8s-master helm]# curl http://192.168.2.151:30140 !DOCTYPE html html head titleWelcome to nginx!/title stylebody {width: 35em;margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif;} /style /head body h1Welcome to nginx!/h1 pIf you see this page, the nginx web server is successfully installed and working. Further configuration is required./p ​ pFor online documentation and support please refer to a hrefhttp://nginx.org/nginx.org/a.br/ Commercial support is available at a hrefhttp://nginx.com/nginx.com/a./p ​ pemThank you for using nginx./em/p /body /html 二.版本更新和回滚问题 1.使用upgrade -f values.yaml或者命令行--set来设置 [rootk8s-master helm]# kubectl describe pod my-nginx-9d774fb48-94wd8 | grep ImageImage:         nginx:1.17.5Image ID:       docker.io/library/nginxsha256:922c815aa4df050d4df476e92daed4231f466acc8ee90e0e774951b0fd7195a4 [rootk8s-master helm]# vim nginx/values.yaml [rootk8s-master helm]# vim nginx/values.yaml [rootk8s-master helm]# helm upgrade -f nginx/values.yaml my-nginx nginx/ Release my-nginx has been upgraded. Happy Helming! NAME: my-nginx LAST DEPLOYED: Mon Mar 18 20:35:40 2024 NAMESPACE: default STATUS: deployed REVISION: 2 NOTES: 1. Get the application URL by running these commands:export NODE_PORT$(kubectl get --namespace default -o jsonpath{.spec.ports[0].nodePort} services my-nginx)export NODE_IP$(kubectl get nodes --namespace default -o jsonpath{.items[0].status.addresses[0].address})echo http://$NODE_IP:$NODE_PORT [rootk8s-master helm]# kubectl get pods NAME                       READY   STATUS             RESTARTS   AGE my-nginx-698cb48f59-v4pbb   0/1     ContainerCreating   0         7s my-nginx-9d774fb48-94wd8   1/1     Running             0         8m48s [rootk8s-master helm]# kubectl get pods NAME                       READY   STATUS   RESTARTS   AGE my-nginx-698cb48f59-v4pbb   1/1     Running   0         64s [rootk8s-master helm]# kubectl describe pod my-nginx-698cb48f59-v4pbb | grep ImageImage:         nginx:1.17.8Image ID:       docker.io/library/nginxsha256:380eb808e2a3b0dd954f92c1cae2f845e6558a15037efefcabc5b4e03d666d03 2.查看历史版本并回滚 [rootk8s-master helm]# helm history my-nginx REVISION UPDATED                 STATUS   CHART     APP VERSION DESCRIPTION     1       Mon Mar 18 20:27:00 2024 superseded nginx-0.1.0 1.16.0     Install complete 2       Mon Mar 18 20:35:40 2024 deployed nginx-0.1.0 1.16.0     Upgrade complete ​ [rootk8s-master helm]# helm rollback my-nginx 1 Rollback was a success! Happy Helming! [rootk8s-master helm]# kubectl get pods NAME                       READY   STATUS   RESTARTS   AGE my-nginx-9d774fb48-9pv7q   1/1     Running   0         5s [rootk8s-master helm]# kubectl describe pods my-nginx-9d774fb48-9pv7q | grep ImageImage:         nginx:1.17.5Image ID:       docker.io/library/nginxsha256:922c815aa4df050d4df476e92daed4231f466acc8ee90e0e774951b0fd7195a4 三.helm模板内管道和函数 1.defautl 也就是和管道符号配合当你values中的值未指定时就使用此默认值 以nginx模版的port为例将其设置为空但设置了默认值为80创建过后仍然会暴露80端口 [rootk8s-master helm]# cat nginx/values.yaml | grep portport: #在deployment文件中引用了此变量的地方设置default [rootk8s-master helm]# cat nginx/templates/deployment.yaml | grep defaultimage: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}containerPort: {{ .Values.service.port | default 80 }}   #这样写#在service文件中引用了此变量的地方设置default [rootk8s-master helm]# cat nginx/templates/service.yaml | grep default- port: {{ .Values.service.port | default 80 }} [rootk8s-master helm]# helm install nginx nginx/ [rootk8s-master helm]# kubectl get pods,svc NAME                         READY   STATUS   RESTARTS   AGE pod/nginx-6467995c7d-gt4g5   1/1     Running   0         8s ​ NAME                 TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)       AGE service/kubernetes   ClusterIP   10.96.0.1       none       443/TCP       113m service/nginx       NodePort   10.106.164.22   none       80:32598/TCP   8s 2.quote 这个表示的是为某个变量设置后无论设定的变量值是什么类型都将其识别为字符串类型书写格式如下 {{ quote .Values.service.port }} 3.indent和nindent indent表示在同一行变量值前设定多少个缩进值nindent表示换行后再在变量值前设置多少个缩进值书写格式如下 {{ .Values.service.port | indent/nindent 10 }} 4.upper 将值都变为大写格式如下 {{ upper .Values.service.port }} 5.title 将首字母设置为大写格式如下 {{ title .Values.service.port }} 6.toYaml 将一整个yaml块都取值取过来一般还需要陪着缩进一起使用格式如下 {{ toYaml .Values.service.port | indent/nindent 10 }}
http://www.w-s-a.com/news/189427/

相关文章:

  • 在网站做推广要钱吗网站根目录是哪个文件夹
  • 网站建设如何弄链接海外vps一键配置WordPress
  • 1个ip可以做几个网站吗动画制作可以自学吗
  • 顺德建设局网站如何搭建网站
  • 精品网站建设费用 干净磐石网络网页制作简单作业
  • 网站建设需要用软件群晖怎样做网站
  • 网站建设公司有哪博客网站建设方案书
  • 服装商城的网站建设宿迁论坛
  • 网站建设服务市场趋势淮南市网站开发的方式
  • 交互设计包含网站设计wordpress和discuz共存
  • 淮阳城乡建设局网站在线网页翻译软件
  • 什么是电商视觉设计郑州seo服务
  • google网站设计原则青海网站建设与管理
  • 简述网站的创建流程广西网站建设定制
  • 唐河网站制作汉中建设工程招标新闻中心
  • 网站过期就可以抢注PHP框架和wordpress
  • 天津做网站得公司克隆网站到wordpress修改
  • 郫县网站建设网站建设报价单及项目收费明细表
  • 商标做网站logo建网站作业
  • 网站顶部展出的大幅广告中建八局第二建设有限公司
  • 公众微信绑定网站帐号优秀中文网页设计
  • 如何做漫画赚钱的网站企业网站管理系统c
  • 安康公司网站制作搜狗网站
  • 太仓住房与城乡建设局网站注册推广赚钱一个80元
  • wordpress 网站生成app企业网站改版的好处
  • 广州建站服务怎么让客户做网站
  • 南京手机网站设计公司wordpress导航页
  • 娄底市建设网站app网站开发小程序
  • 刷粉网站推广免费网站建设找王科杰信誉
  • 投标建设用地是哪个网站微信小程序多少钱