您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“weblogic的部署方法”的有關(guān)知識,在實(shí)際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
請仔細(xì)閱讀:https://my.oschina.net/u/3867634/blog/2246865
至此,我們已經(jīng)構(gòu)建了oracle/weblogic:12.2.1.3-developer鏡像,為了方便后續(xù)使用,我們可以搭建Harbor本地私有鏡像倉庫,將次鏡像push至倉庫中。
請參閱:https://github.com/goharbor/harbor/blob/release-1.6.0/docs/installation_guide.md
中文版:https://blog.csdn.net/aixiaoyang168/article/details/73549898
搭建完成后,kubernetes節(jié)點(diǎn)中需要修改insecure-registry:
//編輯配置docker-option配置文件 vi /etc/systemd/system/docker.service.d/docker-options.conf //在文件中添加 --insecure-registry=172.17.20.25 [Service] Environment="DOCKER_OPTS=--insecure-registry=10.233.0.0/18 --insecure-registry=172.17.20.25 --graph=/var/lib/docker --log-opt max-size=50m --log-opt max-file=5 \ --iptables=false" //重啟docker systemctl daemon-reload systemctl restart docker
然后,將構(gòu)建好的鏡像push至倉庫中:
//給image打標(biāo)簽 docker tag oracle/weblogic:12.1.3-developer 172.17.20.25/oracle/weblogic:12.1.3-developer //push至172.17.20.25 docker push 172.17.20.25/oracle/weblogic:12.1.3-developer
現(xiàn)在,可以登錄至http://172.17.20.25查看鏡像
拉取鏡像:
docker pull 172.17.20.25/oracle/weblogic:12.2.1.3-developer
拉取docker-images代碼:
$ git clone https://github.com/oracle/docker-images.git //進(jìn)入wls-k8s-domain目錄 [root@localhost ~]# cd docker-images/OracleWebLogic/samples/wls-k8s-domain/ [root@localhost wls-k8s-domain]# ls build.sh container-scripts Dockerfile k8s README.md
構(gòu)建wls-k8s-domain鏡像:
$ docker build -t wls-k8s-domain .
將鏡像tag打成172.17.20.25/oracle/wls-k8s-domain:1.0后push至Harbor以方便k8s節(jié)點(diǎn)拉取。
再修改k8s/wls-admin.yml為如下所示:
apiVersion: apps/v1beta1 kind: Deployment metadata: name: admin-server spec: selector: matchLabels: app: admin-server replicas: 1 template: metadata: labels: app: admin-server spec: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: app operator: In values: - admin-server topologyKey: "kubernetes.io/hostname" containers: - name: admin-server #image修改為harbor上的名字 image: 172.17.20.25/oracle/wls-k8s-domain:1.0 imagePullPolicy: IfNotPresent command: ["sh"] args: ["/u01/oracle/startadmin.sh"] readinessProbe: httpGet: path: /weblogic/ready port: 8001 initialDelaySeconds: 15 timeoutSeconds: 5 ports: - containerPort: 8001 env: - name: WLUSER valueFrom: secretKeyRef: name: wlsecret key: username - name: WLPASSWORD valueFrom: secretKeyRef: name: wlsecret key: password volumeMounts: - mountPath: /u01/wlsdomain name: domain-home volumes: - name: domain-home persistentVolumeClaim: claimName: wlserver-pvc-1 --- apiVersion: v1 kind: Service metadata: name: admin-server labels: app: admin-server spec: type: NodePort selector: app: admin-server ports: - name: client protocol: TCP port: 8001 targetPort: 8001 nodePort: 30007 selector: app: admin-server
修改k8s/wls-stateful.yml為:
apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 kind: StatefulSet metadata: name: managed-server spec: serviceName: wls-subdomain selector: matchLabels: app: managed-server replicas: 2 template: metadata: name: ms labels: app: managed-server spec: #將managed-server與admin-server部署在同一個(gè)node上 affinity: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: app operator: In values: - admin-server topologyKey: "kubernetes.io/hostname" subdomain: wls-subdomain containers: - name: managed-server image: 172.17.20.25/oracle/wls-k8s-domain:1.0 imagePullPolicy: IfNotPresent command: ["sh"] args: ["/u01/oracle/startms.sh"] readinessProbe: httpGet: path: /weblogic/ready port: 8011 initialDelaySeconds: 15 timeoutSeconds: 5 ports: - containerPort: 8011 env: - name: JAVA_OPTIONS value: "-Dweblogic.StdoutDebugEnabled=true" - name: USER_MEM_ARGS value: "-Xms64m -Xmx256m " - name: MY_POD_IP valueFrom: fieldRef: fieldPath: status.podIP - name: MY_POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: DNS_DOMAIN_NAME value: "wls-subdomain" - name: WLUSER valueFrom: secretKeyRef: name: wlsecret key: username - name: WLPASSWORD valueFrom: secretKeyRef: name: wlsecret key: password volumeMounts: - mountPath: /u01/wlsdomain name: domain-home - mountPath: /u01/filestores name: filestore-data volumes: - name: domain-home persistentVolumeClaim: claimName: wlserver-pvc-1 - name: filestore-data persistentVolumeClaim: claimName: wlserver-pvc-2 --- apiVersion: v1 # headless service required for statefulSet kind: Service metadata: name: wls-subdomain labels: app: managed-server spec: ports: - name: client port: 8011 protocol: TCP targetPort: 8011 clusterIP: None selector: app: managed-server --- apiVersion: v1 kind: Service metadata: name: wls-service labels: app: managed-server spec: type: NodePort ports: - name: client port: 8011 protocol: TCP targetPort: 8011 nodePort: 30009 selector: app: managed-server
修改k8s/pv.yml
kind: PersistentVolume apiVersion: v1 metadata: name: pv1 labels: app: wls-domain spec: storageClassName: manual capacity: storage: 10Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Recycle # Retain, Recycle, Delete hostPath: #path填上本地目錄 path: "/home/oracle/pv/pv1" #nfs: #server: <nfs_server_ip> #path: <shared_path> --- kind: PersistentVolume apiVersion: v1 metadata: name: pv2 labels: app: wls-domain spec: storageClassName: manual capacity: storage: 10Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Recycle # Retain, Recycle, Delete hostPath: path: "/home/oracle/pv/pv2" #nfs: #server: <nfs_server_ip> #path: <shared_path> --- kind: PersistentVolume apiVersion: v1 metadata: name: pv3 labels: app: wls-domain spec: storageClassName: manual capacity: storage: 10Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Recycle # Retain, Recycle, Delete hostPath: path: "/home/oracle/pv/pv3" #nfs: #server: <nfs_server_ip> #path: <shared_path>
NOTE:hostPath下所填的目錄需有777權(quán)限。
IMPORTANT:在執(zhí)行創(chuàng)建腳本之前,必須確保有一個(gè)用戶的UID和GID為1000:1000。
然后,依次執(zhí)行以下命令:
$ kubectl create -f k8s/secrets.yml $ kubectl create -f k8s/pv.yml $ kubectl create -f k8s/pvc.yml $ kubectl create -f k8s/wls-admin.yml $ kubectl create -f k8s/wls-stateful.yml
至此,一個(gè)帶有兩個(gè)managed-server的domain便創(chuàng)建好了。
$ kubectl get all NAME READY STATUS RESTARTS AGE po/admin-server-1238998015-f932w 1/1 Running 0 11m po/managed-server-0 1/1 Running 0 11m po/managed-server-1 1/1 Running 0 8m NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/admin-server 10.102.160.123 <nodes> 8001:30007/TCP 11m svc/kubernetes 10.96.0.1 <none> 443/TCP 39d svc/wls-service 10.96.37.152 <nodes> 8011:30009/TCP 11m svc/wls-subdomain None <none> 8011/TCP 11m NAME DESIRED CURRENT AGE statefulsets/managed-server 2 2 11m NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/admin-server 1 1 1 1 11m NAME DESIRED CURRENT READY AGE rs/admin-server-1238998015 1 1 1 11m
現(xiàn)在可以登錄http:IP:30007/console訪問控制臺,默認(rèn)賬號為:weblogic,密碼為:weblogic1。
在weblogic中部署的應(yīng)用訪問端口為30009。
我們可以制作chart來一鍵安裝,步驟如下:
1.創(chuàng)建名為hello-world的charts
helm create weblogic
2.將k8s/目錄放入weblogic/templates目錄下
注:helloworld程序簡單,程序不需引入相關(guān)依賴,也不需要傳入?yún)?shù)。charts提供了版本控制,引入依賴,傳參等配置文件。
3.打包tar
helm package weblogic
4.在本地創(chuàng)建charts文件夾,并將打包的tar文件移入,生成index.yaml
mv weblogic-0.1.0.tgz charts/
helm serve --repo-path ./charts
5、安裝chart
helm install weblogic
“weblogic的部署方法”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。