时隔几个月,重拾WebLogic

  • 为什么是WebLogic

简单说一句就是,因为WebLogic在中间件里面够复杂。

  • Server不同的角色
  • AdminServer和Managed Server之间的通讯
  • NodeManager负责AdminServer和Managed Server的启停
  • ManagedServer连上去的认证
  • 状态的保存
  • 域内容的共享

总而言之一句话,就是需要保存状态,需要Persistance,而operator基于一系列脚本将他自动化和脚本化,降低了创建的开销,

但有一点避免不了,就是你必须仍然对WebLogic架构工作原理比较了解,否则任何地方出现问题你都难以定位。

目前Oracle官方出的WebLogic Operator处于Techinical Preview版本阶段,按照官方说法,他提供了创建域,自动的启动,集群扩展,以及和Prometheus集成,web应用的负载均衡器(使用Traefik1.4.5版本),同时提供了ELK的集成功能。

(It provides a mechanism to create domains, automates domain startup, allows scaling WebLogic clusters up and down either manually (on-demand) or through integration with the WebLogic Diagnostics Framework or Prometheus, manages load balancing for web applications deployed in WebLogic clusters, and provides integration with ElasticSearch, logstash and Kibana.)

WebLogic Operator使用标准的WebLogic Server 12.2.1.3的镜像,可以从store/oracle下载获取,当然也可以自己构建,鉴于墙的原因,我就是自己构建的。

  • 架构

总的来说和传统架构类似,重要的是需要有个PV保存共享状态,相当于传统架构中大家mount同一个存储吧。

  • 前序条件

这个比较重要,特别是docker的版本,之前用12的版本,发现死活不work!

Kubernetes 1.7.5+, 1.8.0+

  1. kubectl version

Flannel networking v0.9.1-amd64

Docker 17.03.1.ce

  1. docker version
  • 构建Operator
  1. git clone https://github.com/oracle/weblogic-kubernetes-operator.git

构建weblogic-operator镜像,最后也是以一个pod模式运行在weblogic-operator的命名空间中。

  1. mvn clean install
  2. docker login
  3. docker build -t weblogic-kubernetes-operator:some-tag --no-cache=true .

首先需要有store/oracle/serverjre:8的镜像环境,然后生成weblogic-kubernetes-operator后将镜像save再load到各个需要的节点。

Dockerfile如下

  1. # Copyright , , Oracle Corporation and/or its affiliates. All rights reserved.
  2.  
  3. # using JRE with support for container heap management
  4. #FROM store/oracle/serverjre:
  5. FROM linux7-jre:8u151
  6.  
  7. RUN mkdir /operator
  8. RUN mkdir /operator/lib
  9. ENV PATH=$PATH:/operator
  10.  
  11. COPY src/scripts/* /operator/
  12. COPY operator/target/weblogic-kubernetes-operator-0.2.jar /operator/weblogic-kubernetes-operator.jar
  13. COPY operator/target/lib/*.jar /operator/lib/
  14.  
  15. HEALTHCHECK --interval=1m --timeout=10s \
  16. CMD /operator/livenessProbe.sh
  17.  
  18. WORKDIR /operator/
  19.  
  20. CMD ["/operator/operator.sh"]

基本就是将一大堆脚本和jar包移入镜像,然后再启动operator.sh文件

Operator的源码

  1. [root@k8s-master src]# tree main
  2. main
  3. ├── java
  4.    └── oracle
  5.    └── kubernetes
  6.    └── operator
  7.    ├── authentication
  8.       ├── Authenticator.java
  9.       ├── Helpers.java
  10.       └── package-info.java
  11.    ├── builders
  12.       ├── CallParamsImpl.java
  13.       ├── CallParams.java
  14.       ├── package-info.java
  15.       ├── UncheckedApiException.java
  16.       ├── WatchBuilder.java
  17.       ├── WatchI.java
  18.       └── WatchImpl.java
  19.    ├── ConfigMapWatcher.java
  20.    ├── DomainStatusUpdater.java
  21.    ├── DomainWatcher.java
  22.    ├── EventWatcher.java
  23.    ├── helpers
  24.       ├── AnnotationHelper.java
  25.       ├── AuthenticationProxy.java
  26.       ├── AuthorizationProxy.java
  27.       ├── CallBuilderFactory.java
  28.       ├── CallBuilder.java
  29.       ├── ClientPool.java
  30.       ├── ConfigMapConsumer.java
  31.       ├── ConfigMapHelper.java
  32.       ├── CRDHelper.java
  33.       ├── DomainPresenceInfo.java
  34.       ├── HealthCheckHelper.java
  35.       ├── IngressHelper.java
  36.       ├── package-info.java
  37.       ├── PodHelper.java
  38.       ├── Pool.java
  39.       ├── ResponseStep.java
  40.       ├── RollingHelper.java
  41.       ├── SecretHelper.java
  42.       ├── ServerKubernetesObjectsFactory.java
  43.       ├── ServerKubernetesObjects.java
  44.       └── ServiceHelper.java
  45.    ├── http
  46.       ├── HttpClient.java
  47.       ├── HTTPException.java
  48.       ├── package-info.java
  49.       └── Result.java
  50.    ├── IngressWatcher.java
  51.    ├── KubernetesConstants.java
  52.    ├── LabelConstants.java
  53.    ├── logging
  54.       ├── LoggingFacade.java
  55.       ├── LoggingFactory.java
  56.       ├── LoggingFormatter.java
  57.       ├── MessageKeys.java
  58.       └── package-info.java
  59.    ├── Main.java
  60.    ├── OperatorLiveness.java
  61.    ├── package-info.java
  62.    ├── PodWatcher.java
  63.    ├── ProcessingConstants.java
  64.    ├── rest
  65.       ├── AuthenticationFilter.java
  66.       ├── backend
  67.          ├── package-info.java
  68.          ├── RestBackend.java
  69.          └── VersionUtils.java
  70.       ├── BaseDebugLoggingFilter.java
  71.       ├── ErrorFilter.java
  72.       ├── ExceptionMapper.java
  73.       ├── FilterPriorities.java
  74.       ├── model
  75.          ├── BaseModel.java
  76.          ├── ClusterModel.java
  77.          ├── CollectionModel.java
  78.          ├── DomainModel.java
  79.          ├── ErrorModel.java
  80.          ├── ItemModel.java
  81.          ├── LinkContainerModel.java
  82.          ├── LinkModel.java
  83.          ├── package-info.java
  84.          ├── ScaleClusterParamsModel.java
  85.          └── VersionModel.java
  86.       ├── package-info.java
  87.       ├── RequestDebugLoggingFilter.java
  88.       ├── resource
  89.          ├── BaseResource.java
  90.          ├── ClusterResource.java
  91.          ├── ClustersResource.java
  92.          ├── DomainResource.java
  93.          ├── DomainsResource.java
  94.          ├── package-info.java
  95.          ├── ScaleClusterResource.java
  96.          ├── SwaggerResource.java
  97.          ├── VersionResource.java
  98.          └── VersionsResource.java
  99.       ├── ResponseDebugLoggingFilter.java
  100.       ├── RestBackendImpl.java
  101.       ├── RestConfigImpl.java
  102.       ├── RestConfig.java
  103.       └── RestServer.java
  104.    ├── ServerStatusReader.java
  105.    ├── ServiceWatcher.java
  106.    ├── StartupControlConstants.java
  107.    ├── TuningParametersImpl.java
  108.    ├── TuningParameters.java
  109.    ├── utils
  110.       └── ConcurrentWeakHashMap.java
  111.    ├── watcher
  112.       ├── package-info.java
  113.       └── WatchListener.java
  114.    ├── Watcher.java
  115.    ├── WebLogicConstants.java
  116.    ├── wlsconfig
  117.       ├── NetworkAccessPoint.java
  118.       ├── package-info.java
  119.       ├── WlsClusterConfig.java
  120.       ├── WlsDomainConfig.java
  121.       ├── WlsRetriever.java
  122.       └── WlsServerConfig.java
  123.    └── work
  124.    ├── ComponentEx.java
  125.    ├── Component.java
  126.    ├── ComponentRegistry.java
  127.    ├── Container.java
  128.    ├── ContainerResolver.java
  129.    ├── Engine.java
  130.    ├── FiberGate.java
  131.    ├── Fiber.java
  132.    ├── NextAction.java
  133.    ├── package-info.java
  134.    ├── Packet.java
  135.    ├── Step.java
  136.    └── ThreadLocalContainerResolver.java
  137. ├── javadoc
  138.    └── overview.html
  139. └── resources
  140. └── Operator.properties
  141.  
  142. directories, files
  • 安装指导

详情参考

https://github.com/oracle/weblogic-kubernetes-operator

https://github.com/oracle/weblogic-kubernetes-operator/blob/master/site/installation.md

  1. git clone https://github.com/oracle/weblogic-kubernetes-operator.git

修改create-weblogic-operator-input.yaml文件,主要是 targetNamespaces,

同时修改了镜像 weblogicOperatorImage: weblogic-kubernetes-operator:developer

  1. [root@k8s-master kubernetes]# cat create-weblogic-operator-inputs.yaml
  2. # Copyright , Oracle Corporation and/or its affiliates. All rights reserved.
  3. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
  4.  
  5. # The name of the service account that the operator will use to
  6. # make requests to the Kubernetes API server.
  7. # The name must be lowercase
  8. serviceAccount: weblogic-operator
  9.  
  10. # The Kubernetes namespace that the operator will be deployed in.
  11. # It is recommended that a namespace be created for the operator rather
  12. # than using the default namespace.
  13. # The name must be lowercase
  14. namespace: weblogic-operator
  15.  
  16. # A comma-separated list of target namespaces the operator manages
  17. # The names must be lowercase
  18. targetNamespaces: domain1
  19.  
  20. # The docker image containing the operator code.
  21. #weblogicOperatorImage: container-registry.oracle.com/middleware/weblogic-kubernetes-operator:latest
  22. weblogicOperatorImage: weblogic-kubernetes-operator:developer
  23.  
  24. # The image pull policy for the operator docker image.
  25. weblogicOperatorImagePullPolicy: IfNotPresent
  26.  
  27. # Name of the Kubernetes secret to access the registry containing the operator Docker image
  28. # The presence of the secret will be validated when this parameter is enabled.
  29. #weblogicOperatorImagePullSecretName:
  30.  
  31. # Options for externally exposing the operator REST https interface
  32. # (i.e. outside of the Kubernetes cluster). Valid values are:
  33. #
  34. # "NONE"
  35. # The REST interface is not exposed outside the Kubernetes cluster.
  36. #
  37. # "SELF_SIGNED_CERT"
  38. # The REST interface is exposed outside of the Kubernetes cluster on the
  39. # port specified by the 'externalRestHttpsPort' property.
  40. # A self-signed certificate and private key are generated for the REST interface.
  41. # The certificate's subject alternative names are specified by the 'externalSans'
  42. # property.
  43. #
  44. # "CUSTOM_CERT"
  45. # The REST interface is exposed outside of the Kubernetes cluster on the
  46. # port specified by the 'externalRestHttpsPort' property.
  47. # The customer supplied certificate and private key are used for the REST
  48. # interface. They are specified by the 'externalOperatorCert' and
  49. # 'eternalOperatorKey' properties.
  50. externalRestOption: NONE
  51.  
  52. # The node port that should be allocated for the external operator REST https interface.
  53. # This parameter is required if 'externalRestOption' is not 'NONE'.
  54. # Otherwise, it is ignored.
  55. externalRestHttpsPort:
  56.  
  57. # The subject alternative names to put into the generated self-signed certificate
  58. # for the external WebLogic Operator REST https interface, for example:
  59. # DNS:myhost,DNS:localhost,IP:127.0.0.1
  60. # This parameter is required if 'externalRestOption' is 'SELF_SIGNED_CERT'.
  61. # Otherwise, it is ignored.
  62. externalSans:
  63.  
  64. # The customer supplied certificate to use for the external operator REST
  65. # https interface. The value must be a string containing a base64 encoded PEM certificate.
  66. # This parameter is required if 'externalRestOption' is 'CUSTOM_CERT'.
  67. # Otherwise, it is ignored.
  68. externalOperatorCert:
  69.  
  70. # The customer supplied private key to use for the external operator REST
  71. # https interface. The value must be a string containing a base64 encoded PEM key.
  72. # This parameter is required if 'externalRestOption' is 'CUSTOM_CERT'.
  73. # Otherwise, it is ignored.
  74. externalOperatorKey:
  75.  
  76. # Controls whether or not the operator will start a Java remote debug server on the
  77. # provided port and suspend execution until a remote debugger has attached.
  78. # The 'internalDebugHttpPort' property controls the port number inside the Kubernetes
  79. # cluster and the 'externalDebugHttpPort' property controls the port number outside
  80. # the Kubernetes cluster.
  81. remoteDebugNodePortEnabled: false
  82.  
  83. # The port number inside the Kubernetes cluster for the operator's Java
  84. # remote debug server.
  85. # This parameter is required if 'remoteDebugNodePortEnabled' is true.
  86. # Otherwise, it is ignored.
  87. internalDebugHttpPort:
  88.  
  89. # The node port that should be allocated for the Kubernetes cluster for the operator's
  90. # Java remote debug server.
  91. # This parameter is required if 'remoteDebugNodePortEnabled' is true.
  92. # Otherwise, it is ignored.
  93. externalDebugHttpPort:
  94.  
  95. # The level of Java logging that should be enabled in the operator.
  96. # Valid values are: "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", and "FINEST".
  97. javaLoggingLevel: INFO
  98.  
  99. # Controls whether or not ELK integration is enabled.
  100. elkIntegrationEnabled: false
  1. ./create-weblogic-operator.sh \
  2. -i create-weblogic-operator-inputs.yaml \
  3. -o weblogic-operator-output-directory/

创建日志如下:

  1. [root@k8s-master kubernetes]# ./create-weblogic-operator.sh \
  2. > -i create-weblogic-operator-inputs.yaml \
  3. > -o weblogic-operator-output-directory/
  4. Input parameters being used
  5. export serviceAccount="weblogic-operator"
  6. export namespace="weblogic-operator"
  7. export targetNamespaces="domain1"
  8. export weblogicOperatorImage="weblogic-kubernetes-operator:developer"
  9. export weblogicOperatorImagePullPolicy="IfNotPresent"
  10. export externalRestOption="NONE"
  11. export externalRestHttpsPort=""
  12. export remoteDebugNodePortEnabled="false"
  13. export internalDebugHttpPort=""
  14. export externalDebugHttpPort=""
  15. export javaLoggingLevel="INFO"
  16. export elkIntegrationEnabled="true"
  17.  
  18. The WebLogic Operator REST interface will not be externally exposed
  19. /root/weblogic-kubernetes-operator/kubernetes/internal
  20. Generating a self-signed certificate for the operator's internal https port with the subject alternative names DNS:internal-weblogic-operator-svc,DNS:internal-weblogic-operator-svc.weblogic-operator,DNS:internal-weblogic-operator-svc.weblogic-operator.svc,DNS:internal-weblogic-operator-svc.weblogic-operator.svc.cluster.local
  21. Generating weblogic-operator-output-directory//weblogic-operators/weblogic-operator/weblogic-operator.yaml
  22. Running the weblogic operator security customization script
  23. ...
  24. Generating YAML script weblogic-operator-output-directory//weblogic-operators/weblogic-operator/weblogic-operator-security.yaml to create WebLogic Operator security configuration...
  25. Create the WebLogic Operator Security configuration using kubectl as follows: kubectl create -f weblogic-operator-output-directory//weblogic-operators/weblogic-operator/weblogic-operator-security.yaml
  26. Ensure you start the API server with the --authorization-mode=RBAC option.
  27. Checking to see if the namespace weblogic-operator already exists
  28. The namespace weblogic-operator already exists
  29. Checking the target namespace domain1
  30. Checking to see if the namespace domain1 already exists
  31. The namespace domain1 already exists
  32. Checking to see if the service account weblogic-operator already exists
  33. The service account weblogic-operator already exists
  34. Applying the generated file weblogic-operator-output-directory//weblogic-operators/weblogic-operator/weblogic-operator-security.yaml
  35. namespace "weblogic-operator" configured
  36. serviceaccount "weblogic-operator" configured
  37. clusterrole "weblogic-operator-cluster-role" configured
  38. clusterrole "weblogic-operator-cluster-role-nonresource" configured
  39. clusterrolebinding "weblogic-operator-operator-rolebinding" configured
  40. clusterrolebinding "weblogic-operator-operator-rolebinding-nonresource" configured
  41. clusterrolebinding "weblogic-operator-operator-rolebinding-discovery" configured
  42. clusterrolebinding "weblogic-operator-operator-rolebinding-auth-delegator" configured
  43. clusterrole "weblogic-operator-namespace-role" configured
  44. rolebinding "weblogic-operator-rolebinding" configured
  45. Checking the cluster role weblogic-operator-namespace-role was created
  46. Checking role binding weblogic-operator-rolebinding was created for each target namespace
  47. Checking role binding weblogic-operator-rolebinding for namespace domain1
  48. Checking the cluster role weblogic-operator-cluster-role was created
  49. Checking the cluster role bindings weblogic-operator-operator-rolebinding were created
  50. Deploy ELK...
  51. deployment "elasticsearch" configured
  52. service "elasticsearch" configured
  53. deployment "kibana" configured
  54. service "kibana" configured
  55. Applying the file weblogic-operator-output-directory//weblogic-operators/weblogic-operator/weblogic-operator.yaml
  56. configmap "weblogic-operator-cm" configured
  57. secret "weblogic-operator-secrets" configured
  58. deployment "weblogic-operator" created
  59. service "internal-weblogic-operator-svc" created
  60. Waiting for operator deployment to be ready...
  61. status is , iteration of
  62. Checking the operator labels
  63. Checking the operator pods
  64. Checking the operator Pod status
  65.  
  66. The Oracle WebLogic Server Kubernetes Operator is deployed, the following namespaces are being managed: domain1
  67.  
  68. The following files were generated:
  69. weblogic-operator-output-directory//weblogic-operators/weblogic-operator/create-weblogic-operator-inputs.yaml
  70. weblogic-operator-output-directory//weblogic-operators/weblogic-operator/weblogic-operator.yaml
  71. weblogic-operator-output-directory//weblogic-operators/weblogic-operator/weblogic-operator-security.yaml
  72.  
  73. Completed

创建完成后

创建了domain1和weblogic-operator的命名空间

  1. [root@k8s-master weblogic-operator]# kubectl get namespaces
  2. NAME STATUS AGE
  3. default Active 168d
  4. domain1 Active 17h
  5. kube-public Active 168d
  6. kube-system Active 168d
  7. monitoring Active 112d
  8. weblogic-operator Active 17h

在weblogic-operator下创建的对象

  1. [root@k8s-master weblogic-operator]# kubectl get all -n weblogic-operator
  2. NAME READY STATUS RESTARTS AGE
  3. po/weblogic-operator--dvqv6 / Running 17h
  4.  
  5. NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  6. svc/internal-weblogic-operator-svc 10.254.229.199 <none> /TCP 17h
  7.  
  8. NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
  9. deploy/weblogic-operator 17h
  10.  
  11. NAME DESIRED CURRENT READY AGE
  12. rs/weblogic-operator- 17h

pod的日志信息

  1. [root@k8s-master weblogic-operator]# kubectl logs weblogic-operator--dvqv6 -n weblogic-operator
  2. Launching Oracle WebLogic Server Kubernetes Operator...
  3. {"timestamp":"05-15-2018T00:54:01.857+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.TuningParametersImpl","method":"update","timeInMillis":,"message":"Reloading tuning parameters from Operator's config map","exception":"","code":"","headers":{},"body":""}
  4. {"timestamp":"05-15-2018T00:54:03.431+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.Main","method":"main","timeInMillis":,"message":"Oracle WebLogic Server Kubernetes Operator, version: 0.2, implementation: master.3934b2c, build time: 2018-04-18T17:05:04+0800","exception":"","code":"","headers":{},"body":""}
  5. {"timestamp":"05-15-2018T00:54:03.481+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.Main","method":"startLivenessThread","timeInMillis":,"message":"Starting Operator Liveness Thread","exception":"","code":"","headers":{},"body":""}
  6. {"timestamp":"05-15-2018T00:54:03.601+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.Main","method":"begin","timeInMillis":,"message":"Operator namespace is: weblogic-operator","exception":"","code":"","headers":{},"body":""}
  7. {"timestamp":"05-15-2018T00:54:03.675+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.Main","method":"begin","timeInMillis":,"message":"Operator target namespaces are: domain1","exception":"","code":"","headers":{},"body":""}
  8. {"timestamp":"05-15-2018T00:54:03.680+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.Main","method":"begin","timeInMillis":,"message":"Operator service account is: weblogic-operator","exception":"","code":"","headers":{},"body":""}
  9. {"timestamp":"05-15-2018T00:54:13.180+0000","thread":,"level":"WARNING","class":"oracle.kubernetes.operator.helpers.HealthCheckHelper","method":"logHealthCheckEvent","timeInMillis":,"message":"Access denied for service account system:serviceaccount:weblogic-operator:weblogic-operator for operation get on resource networkpolicies","exception":"","code":"","headers":{},"body":""}
  10. {"timestamp":"05-15-2018T00:54:13.198+0000","thread":,"level":"WARNING","class":"oracle.kubernetes.operator.helpers.HealthCheckHelper","method":"logHealthCheckEvent","timeInMillis":,"message":"Access denied for service account system:serviceaccount:weblogic-operator:weblogic-operator for operation list on resource networkpolicies","exception":"","code":"","headers":{},"body":""}
  11. {"timestamp":"05-15-2018T06:25:48.416+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.helpers.ClientPool","method":"getApiClient","timeInMillis":,"message":"The Kuberenetes Master URL is set to https://10.254.0.1:443","exception":"","code":"","headers":{},"body":""}
  12. {"timestamp":"05-15-2018T06:29:53.941+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.helpers.ClientPool","method":"getApiClient","timeInMillis":,"message":"The Kuberenetes Master URL is set to https://10.254.0.1:443","exception":"","code":"","headers":{},"body":""}
  13. {"timestamp":"05-15-2018T06:42:51.519+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.helpers.ClientPool","method":"getApiClient","timeInMillis":,"message":"The Kuberenetes Master URL is set to https://10.254.0.1:443","exception":"","code":"","headers":{},"body":""}
  14. {"timestamp":"05-15-2018T06:47:45.681+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.helpers.ClientPool","method":"getApiClient","timeInMillis":,"message":"The Kuberenetes Master URL is set to https://10.254.0.1:443","exception":"","code":"","headers":{},"body":""}
  15. {"timestamp":"05-15-2018T06:52:35.717+0000","thread":,"level":"INFO","class":"oracle.kubernetes.operator.helpers.ClientPool","method":"getApiClient","timeInMillis":,"message":"The Kuberenetes Master URL is set to https://10.254.0.1:443","exception":"","code":"","headers":{},"body":""}

客户化资源定义

  1. [root@k8s-master weblogic-operator]# kubectl get crd
  2. NAME KIND
  3. domains.weblogic.oracle CustomResourceDefinition.v1beta1.apiextensions.k8s.io
  • 创建WebLogic Domain

创建secret

  1. kubectl -n domain1 create secret generic domain1-weblogic-credentials --from-literal=username=weblogic --from-literal=password=welcome1

创建pv,域会建立在这个pv下面,持久化在这里,如果你只有一个node,需要在node上建立,当然如果是nfs这种方式就不用

  1. mkdir -m -p /weblogic/domain1PersistentVolume

拉取镜像

  1. docker login
  2. docker pull store/oracle/weblogic:12.2.1.3

这个具体的镜像名是在template文件中定义,我因为拉去不到镜像所以自己build了一个retag了一下。

input文件

  1. [root@k8s-master kubernetes]# cat create-weblogic-domain-inputs.yaml
  2. # Copyright , Oracle Corporation and/or its affiliates. All rights reserved.
  3. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
  4.  
  5. # Port number for admin server
  6. adminPort:
  7.  
  8. # Name of the Admin Server
  9. adminServerName: admin-server
  10.  
  11. # Name of the WebLogic domain to create
  12. domainName: base_domain
  13.  
  14. # Unique id identifying a domain.
  15. # This id must be lowercase and unique across all domains in a Kubernetes cluster.
  16. domainUID: domain1
  17.  
  18. # Determines which WebLogic Servers the Operator will start up
  19. # Legal values are "NONE", "ALL", "ADMIN", "SPECIFIED", or "AUTO"
  20. startupControl: AUTO
  21.  
  22. # Cluster name
  23. clusterName: cluster-
  24.  
  25. # Number of managed servers to generate for the domain
  26. configuredManagedServerCount:
  27.  
  28. # Number of managed servers to initially start for the domain
  29. initialManagedServerReplicas:
  30.  
  31. # Base string used to generate managed server names
  32. managedServerNameBase: managed-server
  33.  
  34. # Port number for each managed server
  35. managedServerPort:
  36.  
  37. # Persistent volume type for the domain's storage.
  38. # The value must be 'HOST_PATH' or 'NFS'.
  39. # If using 'NFS', weblogicDomainStorageNFSServer must be specified.
  40. weblogicDomainStorageType: HOST_PATH
  41.  
  42. # The server name or ip address of the NFS server to use for the domain's storage.
  43. # The following line must be uncomment and customized if weblogicDomainStorateType is NFS:
  44. #weblogicDomainStorageNFSServer: nfsServer
  45.  
  46. # Physical path of the domain's persistent storage.
  47. # The following line must be uncomment and customized:
  48. weblogicDomainStoragePath: /weblogic/domain1PersistentVolume
  49.  
  50. # Reclaim policy of the domain's persistent storage
  51. # The valid values are: 'Retain', 'Delete', and 'Recycle'
  52. weblogicDomainStorageReclaimPolicy: Retain
  53.  
  54. # Total storage allocated to the domain's persistent storage.
  55. weblogicDomainStorageSize: 10Gi
  56.  
  57. # Boolean indicating if production mode is enabled for the domain
  58. productionModeEnabled: true
  59.  
  60. # Name of the Kubernetes secret for the Admin Server's username and password
  61. # The name must be lowercase
  62. weblogicCredentialsSecretName: domain1-weblogic-credentials
  63.  
  64. # Name of the Kubernetes secret to access the Docker Store to pull the WebLogic Server Docker image
  65. # The presence of the secret will be validated when this parameter is enabled.
  66. #weblogicImagePullSecretName:
  67.  
  68. # Port for the T3Channel of the NetworkAccessPoint
  69. t3ChannelPort:
  70.  
  71. # Public address for T3Channel of the NetworkAccessPoint. This value should be set to the
  72. # kubernetes server address, which you can get by running "kubectl cluster-info". If this
  73. # value is not set to that address, WLST will not be able to connect from outside the
  74. # kubernetes cluster.
  75. t3PublicAddress: kubernetes
  76.  
  77. # Boolean to indicate if the channel should be exposed as a service
  78. exposeAdminT3Channel: false
  79.  
  80. # NodePort to expose for the admin server
  81. adminNodePort:
  82.  
  83. # Boolean to indicate if the adminNodePort will be exposed
  84. exposeAdminNodePort: false
  85.  
  86. # Name of the domain namespace
  87. namespace: domain1
  88.  
  89. # Load balancer to deploy. Supported values are:TRAEFIK, NONE
  90. #loadBalancer: TRAEFIK
  91. loadBalancer: NONE
  92.  
  93. # Load balancer web port
  94. loadBalancerWebPort:
  95.  
  96. # Load balancer dashboard port
  97. loadBalancerDashboardPort:
  98.  
  99. #Java Option for Weblogic Server
  100. javaOptions: -Dweblogic.StdoutDebugEnabled=false

运行脚本

  1. ./create-weblogic-domain.sh -i create-weblogic-domain-input.yaml -o weblogic-domain-output/

会先运行一个job pod(domain1-create-weblogic-domain-job-j4bsp),进行域的建立等工作,然后再通过NodeManager将AdminServer和Managed Server一个一个启动起来。

当然在PV下面(node上)看到如下目录

  1. [root@node1 /]# tree weblogic -L
  2. weblogic
  3. └── domain1PersistentVolume
  4. ├── applications
  5. ├── domain
  6.    └── base_domain
  7.    ├── autodeploy
  8.    ├── backup_config
  9.    ├── bin
  10.    ├── config
  11.    ├── console-ext
  12.    ├── edit.lok
  13.    ├── fileRealm.properties
  14.    ├── init-info
  15.    ├── lib
  16.    ├── nodemanager
  17.    ├── orchestration
  18.    ├── resources
  19.    ├── security
  20.    ├── servers
  21.    ├── startManagedWebLogic_readme.txt
  22.    └── startWebLogic.sh
  23. ├── logs
  24.    ├── admin-server.log
  25.    ├── base_domain.log
  26.    ├── nodemanager-admin-server.log
  27.    ├── nodemanager-admin-server.log.lck
  28.    ├── nodemanager-managed-server1.log
  29.    ├── nodemanager-managed-server1.log.lck
  30.    ├── nodemanager-managed-server2.log
  31.    └── nodemanager-managed-server2.log.lck
  32. └── stores

日志如下:

  1. [root@k8s-master kubernetes]# ./create-weblogic-domain.sh -i create-weblogic-domain-inputs.yaml -o weblogic-domain-output/
  2. Input parameters being used
  3. export adminPort=""
  4. export adminServerName="admin-server"
  5. export domainName="base_domain"
  6. export domainUID="domain1"
  7. export startupControl="AUTO"
  8. export clusterName="cluster-1"
  9. export configuredManagedServerCount=""
  10. export initialManagedServerReplicas=""
  11. export managedServerNameBase="managed-server"
  12. export managedServerPort=""
  13. export weblogicDomainStorageType="HOST_PATH"
  14. export weblogicDomainStoragePath="/weblogic/domain1PersistentVolume"
  15. export weblogicDomainStorageReclaimPolicy="Retain"
  16. export weblogicDomainStorageSize="10Gi"
  17. export productionModeEnabled="true"
  18. export weblogicCredentialsSecretName="domain1-weblogic-credentials"
  19. export t3ChannelPort=""
  20. export t3PublicAddress="kubernetes"
  21. export exposeAdminT3Channel="false"
  22. export adminNodePort=""
  23. export exposeAdminNodePort="false"
  24. export namespace="domain1"
  25. export loadBalancer="NONE"
  26. export loadBalancerWebPort=""
  27. export loadBalancerDashboardPort=""
  28. export javaOptions="-Dweblogic.StdoutDebugEnabled=false"
  29.  
  30. Generating weblogic-domain-output//weblogic-domains/domain1/weblogic-domain-pv.yaml
  31. Generating weblogic-domain-output//weblogic-domains/domain1/weblogic-domain-pvc.yaml
  32. Generating weblogic-domain-output//weblogic-domains/domain1/create-weblogic-domain-job.yaml
  33. Generating weblogic-domain-output//weblogic-domains/domain1/domain-custom-resource.yaml
  34. Generating weblogic-domain-output//weblogic-domains/domain1/weblogic-domain-traefik-cluster-1.yaml
  35. Generating weblogic-domain-output//weblogic-domains/domain1/weblogic-domain-traefik-security-cluster-1.yaml
  36. Checking to see if the secret domain1-weblogic-credentials exists in namespace domain1
  37. Checking if the persistent volume domain1-weblogic-domain-pv exists
  38. The persistent volume domain1-weblogic-domain-pv does not exist
  39. Creating the persistent volume domain1-weblogic-domain-pv
  40. persistentvolume "domain1-weblogic-domain-pv" created
  41. Checking if the persistent volume domain1-weblogic-domain-pv is Available
  42. Checking if the persistent volume claim domain1-weblogic-domain-pvc in namespace domain1 exists
  43. No resources found.
  44. The persistent volume claim domain1-weblogic-domain-pvc does not exist in namespace domain1
  45. Creating the persistent volume claim domain1-weblogic-domain-pvc
  46. persistentvolumeclaim "domain1-weblogic-domain-pvc" created
  47. Checking if the persistent volume domain1-weblogic-domain-pv is Bound
  48. Checking if object type job with name domain1-create-weblogic-domain-job exists
  49. No resources found.
  50. Creating the domain by creating the job weblogic-domain-output//weblogic-domains/domain1/create-weblogic-domain-job.yaml
  51. configmap "domain1-create-weblogic-domain-job-cm" created
  52. job "domain1-create-weblogic-domain-job" created
  53. Waiting for the job to complete...
  54. status on iteration of
  55. pod domain1-create-weblogic-domain-job- status is Running
  56. status on iteration of
  57. pod domain1-create-weblogic-domain-job- status is Running
  58. status on iteration of
  59. pod domain1-create-weblogic-domain-job- status is Running
  60. status on iteration of
  61. pod domain1-create-weblogic-domain-job- status is Running
  62. status on iteration of
  63. pod domain1-create-weblogic-domain-job- status is Running
  64. status on iteration of
  65. pod domain1-create-weblogic-domain-job- status is Running
  66. status on iteration of
  67. pod domain1-create-weblogic-domain-job- status is Running
  68. status on iteration of
  69. pod domain1-create-weblogic-domain-job- status is Running
  70. status on iteration of
  71. pod domain1-create-weblogic-domain-job- status is Running
  72. status on iteration of
  73. pod domain1-create-weblogic-domain-job- status is Running
  74. status on iteration of
  75. pod domain1-create-weblogic-domain-job- status is Running
  76. status on iteration of
  77. pod domain1-create-weblogic-domain-job- status is Running
  78. status on iteration of
  79. pod domain1-create-weblogic-domain-job- status is Completed
  80. Creating the domain custom resource using weblogic-domain-output//weblogic-domains/domain1/domain-custom-resource.yaml
  81. domain "domain1" created
  82. Checking the domain custom resource was created
  83.  
  84. Domain base_domain was created and will be started by the WebLogic Kubernetes Operator
  85.  
  86. The following files were generated:
  87. weblogic-domain-output//weblogic-domains/domain1/create-weblogic-domain-inputs.yaml
  88. weblogic-domain-output//weblogic-domains/domain1/weblogic-domain-pv.yaml
  89. weblogic-domain-output//weblogic-domains/domain1/weblogic-domain-pvc.yaml
  90. weblogic-domain-output//weblogic-domains/domain1/create-weblogic-domain-job.yaml
  91. weblogic-domain-output//weblogic-domains/domain1/domain-custom-resource.yaml
  92.  
  93. Completed

完成后看到,在domain1下会生成AdminServer和一个受管实例,处于运行状态中..

[root@k8s-master kubernetes]# kubectl get pod -n domain1

[root@k8s-master kubernetes]# kubectl get pods -n domain1 -w
NAME READY STATUS RESTARTS AGE
domain1-admin-server 0/1 Running 0 44s
domain1-create-weblogic-domain-job-j4bsp 0/1 Completed 0 4m
domain1-admin-server 1/1 Running 0 6m
domain1-managed-server1 0/1 Pending 0 0s
domain1-managed-server1 0/1 Pending 0 0s
domain1-managed-server1 0/1 ContainerCreating 0 0s
domain1-managed-server1 0/1 Running 0 2s
domain1-managed-server1 1/1 Running 0 9m

从这个日志来看,实例的启动有一定的顺序,先AdminServer后Managed Server

  1. [root@k8s-master kubernetes]# kubectl get svc -n domain1
  2. NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. domain1-admin-server 10.254.161.135 <none> /TCP 21m
  4. domain1-cluster-cluster- 10.254.135.246 <none> /TCP 13m
  5. domain1-managed-server1 10.254.68.132 <none> /TCP 13m

看服务,除了admin的7001和managedserver的8001,还多出一个domain1-cluster-cluster-1的服务。

  1. [root@k8s-master kubernetes]# kubectl describe svc domain1-cluster-cluster- -n domain1
  2. Name: domain1-cluster-cluster-
  3. Namespace: domain1
  4. Labels: weblogic.clusterName=cluster-
  5. weblogic.createdByOperator=true
  6. weblogic.domainName=base_domain
  7. weblogic.domainUID=domain1
  8. Annotations: weblogic.oracle/operator-formatVersion=
  9. Selector: weblogic.clusterName=cluster-,weblogic.createdByOperator=true,weblogic.domainUID=domain1
  10. Type: ClusterIP
  11. IP: 10.254.135.246
  12. Port: <unset> /TCP
  13. Endpoints: 10.1.70.9:
  14. Session Affinity: None
  15. Events: <none>

describe 一下,发现这个服务直接指向了守管服务器的地址。

启动完成后,可以describe一下,看到这些实例的参数。

  1. [root@k8s-master ~]# kubectl describe domain domain1 -n domain1
  2. Name: domain1
  3. Namespace: domain1
  4. Labels: weblogic.domainName=base_domain
  5. weblogic.domainUID=domain1
  6. Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"weblogic.oracle/v1","kind":"Domain","metadata":{"annotations":{},"labels":{"weblogic.domainName":"base_domain","weblogic.domainUID":"dom...
  7. API Version: weblogic.oracle/v1
  8. Kind: Domain
  9. Metadata:
  10. Cluster Name:
  11. Creation Timestamp: --16T01::36Z
  12. Generation:
  13. Resource Version:
  14. Self Link: /apis/weblogic.oracle/v1/namespaces/domain1/domains/domain1
  15. UID: 8551c004-58a5-11e8-98e4-080027e2ae0a
  16. Spec:
  17. Admin Secret:
  18. Name: domain1-weblogic-credentials
  19. As Name: admin-server
  20. As Port:
  21. Cluster Startup:
  22. Cluster Name: cluster-
  23. Desired State: RUNNING
  24. Env:
  25. Name: JAVA_OPTIONS
  26. Value: -Dweblogic.StdoutDebugEnabled=false
  27. Name: USER_MEM_ARGS
  28. Value: -Xms64m -Xmx256m
  29. Replicas:
  30. Domain Name: base_domain
  31. Domain UID: domain1
  32. Export T Channels:
  33. Image: store/oracle/weblogic:12.2.1.3
  34. Image Pull Policy: IfNotPresent
  35. Replicas:
  36. Server Startup:
  37. Desired State: RUNNING
  38. Env:
  39. Name: JAVA_OPTIONS
  40. Value: -Dweblogic.StdoutDebugEnabled=false
  41. Name: USER_MEM_ARGS
  42. Value: -Xms64m -Xmx256m
  43. Server Name: admin-server
  44. Startup Control: AUTO
  45. Status:
  46. Conditions:
  47. Last Transition Time: --16T01::.928Z
  48. Reason: ServersReady
  49. Status: True
  50. Type: Available
  51. Servers:
  52. Health:
  53. Activation Time: --16T01::.214Z
  54. Overall Health: ok
  55. Subsystems:
  56. Node Name: node1
  57. Server Name: admin-server
  58. State: RUNNING
  59. Cluster Name: cluster-
  60. Health:
  61. Activation Time: --16T01::.561Z
  62. Overall Health: ok
  63. Subsystems:
  64. Node Name: node1
  65. Server Name: managed-server1
  66. State: RUNNING
  67. Start Time: --16T01::.502Z
  68. Events: <none>

  • 扩展Scale实例

前提是在建立集群的时候需要指定多少个受管服务器,比如5个,但启动时候只启动一个,就可以通过编辑下面的domain1的配置,让operator进行实例的启动。

kubectl edit domain domain1 -n domain1

  1. spec:
  2. adminSecret:
  3. name: domain1-weblogic-credentials
  4. asName: admin-server
  5. asPort:
  6. clusterStartup:
  7. - clusterName: cluster-
  8. desiredState: RUNNING
  9. env:
  10. - name: JAVA_OPTIONS
  11. value: -Dweblogic.StdoutDebugEnabled=false
  12. - name: USER_MEM_ARGS
  13. value: '-Xms64m -Xmx256m '
  14. replicas:
  15. domainName: base_domain
  16. domainUID: domain1
  17. exportT3Channels: []
  1. [root@k8s-master kubernetes]# kubectl get pods -n domain1 -w
  2. NAME READY STATUS RESTARTS AGE
  3. domain1-admin-server / Running 25m
  4. domain1-create-weblogic-domain-job-99qjv / Completed 30m
  5. domain1-managed-server1 / Running 17m
  6. domain1-managed-server2 / Running 27s

集群又会启动ms2.

  • 删除weblogic domain

删除所有的域,删除一个域的命令是 -d domainname

  1. ./delete-weblogic-domain-resources.sh -d all
  2.  
  3. @@ Warning! WebLogic Server pods remaining but wait time exceeds half of max wait seconds. About to directly delete all remaining resources, including the leftover pods.
  4. pod "domain1-create-weblogic-domain-job-phm1n" deleted
  5. job "domain1-create-weblogic-domain-job" deleted
  6. persistentvolumeclaim "domain1-weblogic-domain-pvc" deleted
  7. configmap "domain1-create-weblogic-domain-job-cm" deleted
  8. persistentvolume "domain1-weblogic-domain-pv" deleted
  9. @@ resources remaining after seconds, including WebLogic Server pods. Max wait is seconds.
  • 删除WebLogic Operator
  1. kubectl delete deploy weblogic-operator -n weblogic-operator
  2. kubectl delete service external-weblogic-operator-svc -n weblogic-operator
  3. kubectl delete service internal-weblogic-operator-svc -n weblogic-operator

WebLogic Operator初试的更多相关文章

  1. 采用Operator-sdk轻松将helm chart转为Operator

    去年就接触Operator,从Oracle发布的WebLogic Operator到mySQL Operator,构建的源码一大堆,但感觉一直缺少合适的开发框架能够避免复杂性快速生成, 随着技术的日益 ...

  2. WebLogic SSRF 漏洞 (简要翻译)

    [Ref]http://blog.gdssecurity.com/labs/2015/3/30/weblogic-ssrf-and-xss-cve-2014-4241-cve-2014-4210-cv ...

  3. WebLogic SSRF

    本文主要记录一下Weblogic SSRF 利用的操作过程. 一.WebLogic SSRF漏洞简介 漏洞编号:CVE-2014-4210 漏洞影响: 版本10.0.2,10.3.6 Oracle W ...

  4. weblogic系列漏洞整理 -- 5. weblogic SSRF 漏洞 UDDI Explorer对外开放 (CVE-2014-4210)

    目录 五. weblogic SSRF 漏洞 UDDI Explorer对外开放 (CVE-2014-4210) 1. 利用过程 2. 修复建议 一.weblogic安装 http://www.cnb ...

  5. WebLogic远程命令执行

    靶机说明 目标ip:172.16.53.28(window 2003) 本靶机所针对的序列化漏洞系列以及常见安全问题如下: 弱口令登陆控制台部署war包webshell CVE-2018-2893 C ...

  6. 针对Weblogic测试的一些小总结(转)

    1. 管理员登录页面弱密码 Weblogic的端口一般为7001,弱密码一般为weblogic/Oracle@123 or weblogic,或者根据具体情况进行猜测,公司名,人名等等,再有就可以用b ...

  7. [WEB安全]Weblogic漏洞总结

    0x01 Weblogic简介 1.1 叙述 Weblogic是美国Oracle公司出品的一个应用服务器(application server),确切的说是一个基于Java EE架构的中间件,是用于开 ...

  8. SSRF——weblogic vulhub 漏洞复现及攻击内网redis(一)(附批量检测脚本)

    0X01 概述 SSRF(Server-Side Request Forgery, 服务端请求伪造)利用漏洞可以发起网络请求来攻击内网服务.利用SSRF能实现以下效果:1)        扫描内网(主 ...

  9. 应用安全 - 工具 | 平台 - Weblogic - 漏洞 - 汇总

    控制台路径 | 弱口令  前置条件 /console CVE-2016-0638  Date 类型远程代码执行 影响范围10.3.6, 12.1.2, 12.1.3, 12.2.1  CVE-2016 ...

随机推荐

  1. js判断文件格式及大小

      //判断照片大小 function getPhotoSize(obj){     photoExt=obj.value.substr(obj.value.lastIndexOf(".&q ...

  2. android studio 入门比较好的书籍

    http://blog.csdn.NET/aqi00/article/details/50012511 http://blog.csdn.net/aqi00/article/details/73065 ...

  3. php详解和优化

    nginx结合php使用FastCGI方式 apache结合php,php是作为一个模块加载到apache中 (1)FastCGI工作原理 1.用户发送http请求报文给nginx服务器 2.ngin ...

  4. AttributeError: 'ForeignKey' object has no attribute 're' 解决办法

    使用 field_object.rel.model.objects.filter(**db_condition) 报错 forekey中存在rel,为什么不能调用? 通过以下语句观察 print(fi ...

  5. VS2013下实现移动端的跨平台开发

    http://www.th7.cn/Program/Android/201412/336394.shtml 前一天准备下载VS2015预览版,到VisualStudio官网一看,发现微软发布了Visu ...

  6. CF #502

    #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include ...

  7. Flume学习应用:Java写日志数据到MongoDB

    概述 Windows平台:Java写日志到Flume,Flume最终把日志写到MongoDB. 系统环境 操作系统:win7 64 JDK:1.6.0_43 资源下载 Maven:3.3.3下载.安装 ...

  8. Oracle常用常考集合

    登陆远程服务器 sqlplus scott/tiger@192.168.2.1[:port]/sid [as sysdba] 简单查询 select  table_name from user_tab ...

  9. 【BZOJ 1053】 1053: [HAOI2007]反素数ant (反素数)

    1053: [HAOI2007]反素数ant Description 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4.如果某个正整数x满足:g(x)>g(i) 0&l ...

  10. 【树形dp】vijos P1180 选课

    题解: http://www.cppblog.com/rakerichard/articles/105004.html 惊了,讨论子树大小能否dp真鸡儿麻烦,按照上面那份题解,可以不用分这么多类,可以 ...