OpenShift 4.1 演示

功能演示主要包含三个方面.

1. 管理控制台

push镜像发布应用

podman build -t mytomcat:slim .

podman tag  localhost/mytomcat:slim default-route-openshift-image-registry.apps.cluster-d60b.sandbox509.opentlc.com/myproject/mytomcat:slim

podman push default-route-openshift-image-registry.apps.cluster-d60b.sandbox509.opentlc.com/myproject/mytomcat:slim

 

 

[root@clientvm 0 ~]# oc new-app mytomcat:slim --name=demo
--> Found image ec32b2c (4 days old) in image stream "myproject/mytomcat" under tag "slim" for "mytomcat:slim"

    * This image will be deployed in deployment config "demo"
    * Port 8080/tcp will be load balanced by service "demo"
      * Other containers can access this service through the hostname "demo"
    * WARNING: Image "myproject/mytomcat:slim" runs as the 'root' user which may not be permitted by your cluster administrator

--> Creating resources ...
    imagestreamtag.image.openshift.io "demo:slim" created
    deploymentconfig.apps.openshift.io "demo" created
    service "demo" created
--> Success
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose svc/demo' 
    Run 'oc status' to view your app.

 

 

[root@clientvm 0 ~]# oc expose svc/demo
route.route.openshift.io/demo exposed

[root@clientvm 1 ~]# oc get route
NAME       HOST/PORT                                                     PATH   SERVICES   PORT       TERMINATION   WILDCARD
demo       demo-myproject.apps.cluster-8447.sandbox452.opentlc.com              demo       8080-tcp                 None
mytomcat   mytomcat-myproject.apps.cluster-8447.sandbox452.opentlc.com          mytomcat   8080-tcp                 None

 

2. machine和machinesets

 

部署一个cluster-autoscaler

oc get deployments -n openshift-machine-api cluster-autoscaler-operator

echo '
---
apiVersion: "autoscaling.openshift.io/v1"
kind: "ClusterAutoscaler"
metadata:
  name: "default"
spec:
  podPriorityThreshold: -10
  resourceLimits:
    maxNodesTotal: 12
  scaleDown:
    enabled: true
    delayAfterAdd: 10s
    delayAfterDelete: 10s
    delayAfterFailure: 10s' | oc create -f - -n openshift-machine-api


oc get pod -n openshift-machine-api

 

 部署一个machineautoscaler

for ms in cluster-8447-sd4tq-worker-ap-southeast-1c
do
echo "
---
apiVersion: \"autoscaling.openshift.io/v1beta1\"
kind: "MachineAutoscaler"
metadata:
  name: autoscale-${ms}
  namespace: \"openshift-machine-api\"
spec:
  minReplicas: 1
  maxReplicas: 5
  scaleTargetRef:
    apiVersion: machine.openshift.io/v1beta1
    kind: MachineSet
    name: ${ms}" >$HOME/autoscaler-${ms}.yaml
done

 

创建一个压力应用

oc new-project work-queue

echo '
---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: work-queue-
spec:
  template:
    spec:
      containers:
      - name: work
        image: busybox
        command: ["sleep",  "300"]
        resources:
          requests:
            memory: 500Mi
            cpu: 500m
      restartPolicy: Never
      nodeSelector:
        failure-domain.beta.kubernetes.io/zone: ap-southeast-1c
  backoffLimit: 4
  completions: 50
  parallelism: 50' | oc create -f - -n work-queue

 

监控machine和nodes的变化

watch oc get machines -n openshift-machine-api

watch oc get nodes

 

3. Operator

  • 部署一个etcd Operator

 

  • 部署一个kafka Operator

 

posted @ 2019-08-26 11:26  ericnie  阅读(837)  评论(0编辑  收藏  举报