Upgrade the Operator

The tasks in this section show you how to upgrade the Operator to a new patch or patchset. You can perform an Operator upgrade while there are TimesTenClassic and TimesTenScaleout objects deployed in your namespace.

Let's first update the Kubernetes cluster with the new CRD and service account.

  1. On your development host, change to the new_kube_files directory. Next, replace the CRD running in your Kubernetes cluster.
    cd new_kube_files
    kubectl replace -f crd.yaml

    The output is the following.

    customresourcedefinition.apiextensions.k8s.io/
    timestenclassics.timesten.oracle.com/timestenscaleouts.timesten.oracle.com replaced
    
  2. Replace the service account.
    kubectl replace -f service_account.yaml
    The output is the following.
    role.rbac.authorization.k8s.io/timesten-operator replaced
    serviceaccount/timesten-operator replaced
    rolebinding.rbac.authorization.k8s.io/timesten-operator replaced
    

    Next, let's upgrade the Operator.

  3. (Optional): Confirm there is an Operator running.
    kubectl get pods

    The output is similar to the following.

    NAME                                 READY   STATUS    RESTARTS        AGE
    sample-0                             2/2     Running   0               14h
    sample-1                             2/2     Running   0               14h
    sample2-0                            2/2     Running   0               14h
    sample2-1                            2/2     Running   0               14h
    timesten-operator-778878dc6b-4mc77   1/1     Running   0               15h
    

    The name of the Operator is timesten-operator-778878dc6b-4mc77. The other Pods are associated with sample and sample2 TimesTenClassic objects in your namespace.

  4. Upgrade the timesten-operator Deployment.
    Edit these fields in the operator.yaml file:
    • replicas: 1

      Replace 1 with the number of copies of the Operator that you want to run. A value of 1 is acceptable for development and testing. However, you can run more than one replica for high availability purposes.

    • Replace sekret with the name of the image pull secret that you want Kubernetes to use to pull images from your registry.

    • Replace the image line to reference the new TimesTen container image. In this example, the new image is container-registry.oracle.com/timesten/timesten:22.1.1.19.0.

    vi operator.yaml
    
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: timesten-operator
    spec:
      replicas: 1
      selector:
        matchLabels:
          name: timesten-operator
      template:
        metadata:
          labels:
            name: timesten-operator
        spec:
          serviceAccountName: timesten-operator
          imagePullSecrets:
          - name: sekret
          containers:
            - name: timesten-operator
              image: container-registry.oracle.com/timesten/timesten:22.1.1.19.0
              command:
              - /timesten/operator/operator/timesten-operator
              imagePullPolicy: Always
              env:
                - name: WATCH_NAMESPACE
                  valueFrom:
                    fieldRef:
                      fieldPath: metadata.namespace
                - name: POD_NAME
                  valueFrom:
                    fieldRef:
                      fieldPath: metadata.name
                - name: OPERATOR_NAME
                  value: "timesten-operator"
              securityContext:
                  runAsNonRoot: true
                  privileged: false
                  allowPrivilegeEscalation: false
                  capabilities:
                      drop:
                        - all
  5. Update the timesten-operator Deployment.
    kubectl replace -f operator.yaml
    The output is the following.
    deployment.apps/timesten-operator replaced
  6. Verify that the new Operator is running.
    kubectl get pods

    The output is similar to the following.

    NAME                                 READY   STATUS    RESTARTS     AGE
    sample-0                             2/2     Running   0            15h
    sample-1                             2/2     Running   0            15h
    sample2-0                            2/2     Running   0            15h
    sample2-1                            2/2     Running   0            15h
    timesten-operator-6f9d96bdfc-h22lm   1/1     Running   0            9s

    The name of the new Operator is timesten-operator-6f9d96bdfc-h22lm.

  7. Review the new timesten-operator Deployment.
    kubectl describe deployment timesten-operator

    The output is similar to the following.

    Name:                   timesten-operator
    Namespace:              mynamespace
    CreationTimestamp:      Sun, 08 Jan 2023 01:22:28 +0000
    Labels:                 <none>
    Annotations:            deployment.kubernetes.io/revision: 3
    Selector:               name=timesten-operator
    Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
    StrategyType:           RollingUpdate
    MinReadySeconds:        0
    RollingUpdateStrategy:  25% max unavailable, 25% max surge
    Pod Template:
      Labels:           name=timesten-operator
      Service Account:  timesten-operator
      Containers:
       timesten-operator:
        Image:      container-registry.oracle.com/timesten/timesten:22.1.1.19.0
        Port:       <none>
        Host Port:  <none>
        Command:
          /timesten/operator/operator/timesten-operator
        Environment:
          WATCH_NAMESPACE:   (v1:metadata.namespace)
          POD_NAME:          (v1:metadata.name)
          OPERATOR_NAME:    timesten-operator
        Mounts:             <none>
      Volumes:              <none>
    Conditions:
      Type           Status  Reason
      ----           ------  ------
      Available      True    MinimumReplicasAvailable
      Progressing    True    NewReplicaSetAvailable
    OldReplicaSets:  <none>
    NewReplicaSet:   timesten-operator-6f9d96bdfc (1/1 replicas created)
    Events:
      ...

You have successfully updated the timesten-operator Deployment. The new Operator is using the container-registry.oracle.com/timesten/timesten:22.1.1.19.0 container image, and is automatically managing any existing TimesTenClassic and TimesTenScaleout objects in your namespace.