以下示例是关于golang中包含api.ServiceType用法的示例代码,想了解api.ServiceType的具体用法?api.ServiceType怎么用?api.ServiceType使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。
208// If the NodePort value is 0, just the servicePort is used, otherwise, a node port is exposed.
209func createPortAndServiceSpec(servicePort int, targetServicePort int, nodePort int, servicePortName string, extraServicePorts []api.ServicePort) ([]api.ServicePort, api.ServiceType) {
210 //Use the Cluster IP type for the service port if NodePort isn't provided.
215 TargetPort: intstr.FromInt(targetServicePort)}}
216 serviceType := api.ServiceTypeClusterIP
217 if nodePort > 0 {
218 servicePorts[0].NodePort = int32(nodePort)
219 serviceType = api.ServiceTypeNodePort
220 }
240// doesn't already exist.
241func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []api.ServicePort, serviceType api.ServiceType, reconcile bool) error {
242 if s, err := c.ServiceClient.Services(metav1.NamespaceDefault).Get(serviceName, metav1.GetOptions{}); err == nil {
437// * updateMasterService is called periodically from all apiservers.
438func getMasterServiceUpdateIfNeeded(svc *api.Service, servicePorts []api.ServicePort, serviceType api.ServiceType) (s *api.Service, updated bool) {
439 // Determine if the service is in the format we expect
208// If the NodePort value is 0, just the servicePort is used, otherwise, a node port is exposed.
209func createPortAndServiceSpec(servicePort int, targetServicePort int, nodePort int, servicePortName string, extraServicePorts []api.ServicePort) ([]api.ServicePort, api.ServiceType) {
210 //Use the Cluster IP type for the service port if NodePort isn't provided.
215 TargetPort: intstr.FromInt(targetServicePort)}}
216 serviceType := api.ServiceTypeClusterIP
217 if nodePort > 0 {
218 servicePorts[0].NodePort = int32(nodePort)
219 serviceType = api.ServiceTypeNodePort
220 }
240// doesn't already exist.
241func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []api.ServicePort, serviceType api.ServiceType, reconcile bool) error {
242 if s, err := c.ServiceClient.Services(metav1.NamespaceDefault).Get(serviceName, metav1.GetOptions{}); err == nil {
437// * updateMasterService is called periodically from all apiservers.
438func getMasterServiceUpdateIfNeeded(svc *api.Service, servicePorts []api.ServicePort, serviceType api.ServiceType) (s *api.Service, updated bool) {
439 // Determine if the service is in the format we expect
553 servicePorts []api.ServicePort
554 serviceType api.ServiceType
555 expectCreate *api.Service // nil means none expected
562 },
563 serviceType: api.ServiceTypeClusterIP,
564 expectCreate: &api.Service{
572 SessionAffinity: api.ServiceAffinityClientIP,
573 Type: api.ServiceTypeClusterIP,
574 },
607 servicePorts []api.ServicePort
608 serviceType api.ServiceType
609 service *api.Service
617 },
618 serviceType: api.ServiceTypeClusterIP,
619 service: &api.Service{
553 servicePorts []api.ServicePort
554 serviceType api.ServiceType
555 expectCreate *api.Service // nil means none expected
562 },
563 serviceType: api.ServiceTypeClusterIP,
564 expectCreate: &api.Service{
572 SessionAffinity: api.ServiceAffinityClientIP,
573 Type: api.ServiceTypeClusterIP,
574 },
607 servicePorts []api.ServicePort
608 serviceType api.ServiceType
609 service *api.Service
617 },
618 serviceType: api.ServiceTypeClusterIP,
619 service: &api.Service{
208// If the NodePort value is 0, just the servicePort is used, otherwise, a node port is exposed.
209func createPortAndServiceSpec(servicePort int, nodePort int, servicePortName string, extraServicePorts []api.ServicePort) ([]api.ServicePort, api.ServiceType) {
210 //Use the Cluster IP type for the service port if NodePort isn't provided.
215 TargetPort: intstr.FromInt(servicePort)}}
216 serviceType := api.ServiceTypeClusterIP
217 if nodePort > 0 {
218 servicePorts[0].NodePort = int32(nodePort)
219 serviceType = api.ServiceTypeNodePort
220 }
240// doesn't already exist.
241func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []api.ServicePort, serviceType api.ServiceType, reconcile bool) error {
242 ctx := api.NewDefaultContext()
441// * updateMasterService is called periodically from all apiservers.
442func getMasterServiceUpdateIfNeeded(svc *api.Service, servicePorts []api.ServicePort, serviceType api.ServiceType) (s *api.Service, updated bool) {
443 // Determine if the service is in the format we expect
170// If the NodePort value is 0, just the servicePort is used, otherwise, a node port is exposed.
171func createPortAndServiceSpec(servicePort int, nodePort int, servicePortName string, extraServicePorts []api.ServicePort) ([]api.ServicePort, api.ServiceType) {
172 //Use the Cluster IP type for the service port if NodePort isn't provided.
177 TargetPort: intstr.FromInt(servicePort)}}
178 serviceType := api.ServiceTypeClusterIP
179 if nodePort > 0 {
180 servicePorts[0].NodePort = int32(nodePort)
181 serviceType = api.ServiceTypeNodePort
182 }
202// doesn't already exist.
203func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []api.ServicePort, serviceType api.ServiceType, reconcile bool) error {
204 ctx := api.NewDefaultContext()
401// * updateMasterService is called periodically from all apiservers.
402func getMasterServiceUpdateIfNeeded(svc *api.Service, servicePorts []api.ServicePort, serviceType api.ServiceType) (s *api.Service, updated bool) {
403 // Determine if the service is in the format we expect
156// If the NodePort value is 0, just the servicePort is used, otherwise, a node port is exposed.
157func createPortAndServiceSpec(servicePort int, nodePort int, servicePortName string, extraServicePorts []api.ServicePort) ([]api.ServicePort, api.ServiceType) {
158 //Use the Cluster IP type for the service port if NodePort isn't provided.
163 TargetPort: intstr.FromInt(servicePort)}}
164 serviceType := api.ServiceTypeClusterIP
165 if nodePort > 0 {
166 servicePorts[0].NodePort = nodePort
167 serviceType = api.ServiceTypeNodePort
168 }
188// doesn't already exist.
189func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []api.ServicePort, serviceType api.ServiceType, reconcile bool) error {
190 ctx := api.NewDefaultContext()
347// * updateMasterService is called periodically from all apiservers.
348func getMasterServiceUpdateIfNeeded(svc *api.Service, servicePorts []api.ServicePort, serviceType api.ServiceType) (s *api.Service, updated bool) {
349 // Determine if the service is in the format we expect
554 servicePorts []api.ServicePort
555 serviceType api.ServiceType
556 expectCreate *api.Service // nil means none expected
563 },
564 serviceType: api.ServiceTypeClusterIP,
565 expectCreate: &api.Service{
573 SessionAffinity: api.ServiceAffinityClientIP,
574 Type: api.ServiceTypeClusterIP,
575 },
601 servicePorts []api.ServicePort
602 serviceType api.ServiceType
603 service *api.Service
611 },
612 serviceType: api.ServiceTypeClusterIP,
613 service: &api.Service{
494 servicePorts []api.ServicePort
495 serviceType api.ServiceType
496 expectCreate *api.Service // nil means none expected
503 },
504 serviceType: api.ServiceTypeClusterIP,
505 expectCreate: &api.Service{
513 SessionAffinity: api.ServiceAffinityClientIP,
514 Type: api.ServiceTypeClusterIP,
515 },
541 servicePorts []api.ServicePort
542 serviceType api.ServiceType
543 service *api.Service
551 },
552 serviceType: api.ServiceTypeClusterIP,
553 service: &api.Service{
1// Copyright 2011 Google Inc. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package main
6
7import (
8 "bytes"
9 "encoding/json"
10 "errors"
11 "flag"
12 "fmt"
13 "go/format"
14 "io"
15 "io/ioutil"
本文地址:https://www.itbaoku.cn/snippets/415631.html