Restoring OKD components

You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see [4]

You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see [4]

Overview

In OKD, you can restore your cluster and its components by recreating cluster elements, including nodes and applications, from separate storage.

To restore a cluster, you must first back it up.

The following process describes a generic way of restoring applications and the OKD cluster. It cannot take into account custom requirements. You might need to take additional actions to restore your cluster.

Restoring a cluster

To restore a cluster, first reinstall OKD.

Procedure

  1. Reinstall OKD in the same way that you originally installed OKD.

  2. Run all of your custom post-installation steps, such as changing services outside of the control of OKD or installing extra services like monitoring agents.

Restoring a master host backup

After creating a backup of important master host files, if they become corrupted or accidentally removed, you can restore the files by copying the files back to master, ensuring they contain the proper content, and restarting the affected services.

Procedure

  1. Restore the /etc/origin/master/master-config.yaml file:

    1. # MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)*
    2. # cp /etc/origin/master/master-config.yaml /etc/origin/master/master-config.yaml.old
    3. # cp /backup/$(hostname)/$(date +%Y%m%d)/origin/master/master-config.yaml /etc/origin/master/master-config.yaml
    4. # master-restart api
    5. # master-restart controllers

    Restarting the master services can lead to downtime. However, you can remove the master host from the highly available load balancer pool, then perform the restore operation. Once the service has been properly restored, you can add the master host back to the load balancer pool.

    Perform a full reboot of the affected instance to restore the iptables configuration.

  2. If you cannot restart OKD because packages are missing, reinstall the packages.

    1. Get the list of the current installed packages:

      1. $ rpm -qa | sort > /tmp/current_packages.txt
    2. View the differences between the package lists:

      1. $ diff /tmp/current_packages.txt ${MYBACKUPDIR}/packages.txt
      2. > ansible-2.4.0.0-5.el7.noarch
    3. Reinstall the missing packages:

      1. # yum reinstall -y <packages> (1)
      1Replace <packages> with the packages that are different between the package lists.
  3. Restore a system certificate by copying the certificate to the /etc/pki/ca-trust/source/anchors/ directory and execute the update-ca-trust:

    1. $ MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)*
    2. $ sudo cp ${MYBACKUPDIR}/external_certificates/my_company.crt /etc/pki/ca-trust/source/anchors/
    3. $ sudo update-ca-trust

    Always ensure the user ID and group ID are restored when the files are copied back, as well as the SELinux context.

Restoring a node host backup

After creating a backup of important node host files, if they become corrupted or accidentally removed, you can restore the file by copying back the file, ensuring it contains the proper content and restart the affected services.

Procedure

  1. Restore the /etc/origin/node/node-config.yaml file:

    1. # MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d)
    2. # cp /etc/origin/node/node-config.yaml /etc/origin/node/node-config.yaml.old
    3. # cp /backup/$(hostname)/$(date +%Y%m%d)/etc/origin/node/node-config.yaml /etc/origin/node/node-config.yaml
    4. # reboot

Restarting the services can lead to downtime. See Node maintenance, for tips on how to ease the process.

Perform a full reboot of the affected instance to restore the iptables configuration.

  1. If you cannot restart OKD because packages are missing, reinstall the packages.

    1. Get the list of the current installed packages:

      1. $ rpm -qa | sort > /tmp/current_packages.txt
    2. View the differences between the package lists:

      1. $ diff /tmp/current_packages.txt ${MYBACKUPDIR}/packages.txt
      2. > ansible-2.4.0.0-5.el7.noarch
    3. Reinstall the missing packages:

      1. # yum reinstall -y <packages> (1)
      1Replace <packages> with the packages that are different between the package lists.
  2. Restore a system certificate by copying the certificate to the /etc/pki/ca-trust/source/anchors/ directory and execute the update-ca-trust:

    1. $ MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)*
    2. $ sudo cp ${MYBACKUPDIR}/etc/pki/ca-trust/source/anchors/my_company.crt /etc/pki/ca-trust/source/anchors/
    3. $ sudo update-ca-trust

    Always ensure proper user ID and group ID are restored when the files are copied back, as well as the SELinux context.

Restoring etcd

The restore procedure for etcd configuration files replaces the appropriate files, then restarts the service or static pod.

If an etcd host has become corrupted and the /etc/etcd/etcd.conf file is lost, restore it using:

  1. $ ssh master-0
  2. # cp /backup/yesterday/master-0-files/etcd.conf /etc/etcd/etcd.conf
  3. # restorecon -Rv /etc/etcd/etcd.conf
  4. # systemctl restart etcd.service

In this example, the backup file is stored in the /backup/yesterday/master-0-files/etcd.conf path where it can be used as an external NFS share, S3 bucket, or other storage solution.

If you run etcd as a static pod, follow only the steps in that section. If you run etcd as a separate service on either master or standalone nodes, follow the steps to restore v2 or v3 data as required.

Restoring etcd v2 & v3 data

The following process restores healthy data files and starts the etcd cluster as a single node, then adds the rest of the nodes if an etcd cluster is required.

Procedure

  1. Stop all etcd services by removing the etcd pod definition and rebooting the host:

    1. # mkdir -p /etc/origin/node/pods-stopped
    2. # mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/
    3. # reboot
  2. To ensure the proper backup is restored, delete the etcd directories:

    • To back up the current etcd data before you delete the directory, run the following command:

      1. # mv /var/lib/etcd /var/lib/etcd.old
      2. # mkdir /var/lib/etcd
      3. # restorecon -Rv /var/lib/etcd/
    • Or, to delete the directory and the etcd, data, run the following command:

      1. # rm -Rf /var/lib/etcd/*

      In an all-in-one cluster, the etcd data directory is located in the /var/lib/origin/openshift.local.etcd directory.

  3. Restore a healthy backup data file to each of the etcd nodes. Perform this step on all etcd hosts, including master hosts collocated with etcd.

    1. # cp -R /backup/etcd-xxx/* /var/lib/etcd/
    2. # mv /var/lib/etcd/db /var/lib/etcd/member/snap/db
    3. # chcon -R --reference /backup/etcd-xxx/* /var/lib/etcd/
  4. Run the etcd service on each host, forcing a new cluster.

    This creates a custom file for the etcd service, which overwrites the execution command adding the --force-new-cluster option:

    1. # mkdir -p /etc/systemd/system/etcd.service.d/
    2. # echo "[Service]" > /etc/systemd/system/etcd.service.d/temp.conf
    3. # echo "ExecStart=" >> /etc/systemd/system/etcd.service.d/temp.conf
    4. # sed -n '/ExecStart/s/"$/ --force-new-cluster"/p' \
    5. /usr/lib/systemd/system/etcd.service \
    6. >> /etc/systemd/system/etcd.service.d/temp.conf
    7. # systemctl daemon-reload
    8. # master-restart etcd
  5. Check for error messages:

    1. $ master-logs etcd etcd
  6. Check for health status:

    1. # etcdctl2 cluster-health
    2. member 5ee217d17301 is healthy: got healthy result from https://192.168.55.8:2379
    3. cluster is healthy
  7. Restart the etcd service in cluster mode:

    1. # rm -f /etc/systemd/system/etcd.service.d/temp.conf
    2. # systemctl daemon-reload
    3. # master-restart etcd
  8. Check for health status and member list:

    1. # etcdctl2 cluster-health
    2. member 5ee217d17301 is healthy: got healthy result from https://192.168.55.8:2379
    3. cluster is healthy
    4. # etcdctl2 member list
    5. 5ee217d17301: name=master-0.example.com peerURLs=http://localhost:2380 clientURLs=https://192.168.55.8:2379 isLeader=true
  9. After the first instance is running, you can restore the rest of your etcd servers.

Fix the peerURLS parameter

After restoring the data and creating a new cluster, the peerURLs parameter shows localhost instead of the IP where etcd is listening for peer communication:

  1. # etcdctl2 member list
  2. 5ee217d17301: name=master-0.example.com peerURLs=http://*localhost*:2380 clientURLs=https://192.168.55.8:2379 isLeader=true
Procedure
  1. Get the member ID using etcdctl member list:

    1. `etcdctl member list`
  2. Get the IP where etcd listens for peer communication:

    1. $ ss -l4n | grep 2380
  3. Update the member information with that IP:

    1. # etcdctl2 member update 5ee217d17301 https://192.168.55.8:2380
    2. Updated member with ID 5ee217d17301 in cluster
  4. To verify, check that the IP is in the member list:

    1. $ etcdctl2 member list
    2. 5ee217d17301: name=master-0.example.com peerURLs=https://*192.168.55.8*:2380 clientURLs=https://192.168.55.8:2379 isLeader=true

Restoring etcd v3 snapshot

The restore procedure for v3 data is similar to the restore procedure for the v2 data.

Snapshot integrity may be optionally verified at restore time. If the snapshot is taken with etcdctl snapshot save, it will have an integrity hash that is checked by etcdctl snapshot restore. If the snapshot is copied from the data directory, there is no integrity hash and it will only restore by using --skip-hash-check.

The procedure to restore the data must be performed on a single etcd host. You can then add the rest of the nodes to the cluster.

Procedure

  1. Stop all etcd services by removing the etcd pod definition and rebooting the host:

    1. # mkdir -p /etc/origin/node/pods-stopped
    2. # mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/
    3. # reboot
  2. Clear all old data, because etcdctl recreates it in the node where the restore procedure is going to be performed:

    1. # rm -Rf /var/lib/etcd
  3. Run the snapshot restore command, substituting the values from the /etc/etcd/etcd.conf file:

    1. # etcdctl3 snapshot restore /backup/etcd-xxxxxx/backup.db \
    2. --data-dir /var/lib/etcd \
    3. --name master-0.example.com \
    4. --initial-cluster "master-0.example.com=https://192.168.55.8:2380" \
    5. --initial-cluster-token "etcd-cluster-1" \
    6. --initial-advertise-peer-urls https://192.168.55.8:2380 \
    7. --skip-hash-check=true
    8. 2017-10-03 08:55:32.440779 I | mvcc: restore compact to 1041269
    9. 2017-10-03 08:55:32.468244 I | etcdserver/membership: added member 40bef1f6c79b3163 [https://192.168.55.8:2380] to cluster 26841ebcf610583c
  4. Restore permissions and selinux context to the restored files:

    1. # restorecon -Rv /var/lib/etcd
  5. Start the etcd service:

    1. # systemctl start etcd
  6. Check for any error messages:

    1. # master-logs etcd etcd

Restoring etcd on a static pod

Before restoring etcd on a static pod:

  • etcdctl binaries must be available or, in containerized installations, the rhel7/etcd container must be available.

    You can obtain etcd by running the following commands:

    1. $ git clone https://github.com/coreos/etcd.git
    2. $ cd etcd
    3. $ ./build

To restore etcd on a static pod:

  1. If the pod is running, stop the etcd pod by moving the pod manifest YAML file to another directory:

    1. $ mv /etc/origin/node/pods/etcd.yaml .
  2. Clear all old data:

    1. $ rm -rf /var/lib/etcd

    You use the etcdctl to recreate the data in the node where you restore the pod.

  3. Restore the etcd snapshot to the mount path for the etcd pod:

    1. $ export ETCDCTL_API=3
    2. $ etcdctl snapshot restore /etc/etcd/backup/etcd/snapshot.db
    3. --data-dir /var/lib/etcd/
    4. --name ip-172-18-3-48.ec2.internal
    5. --initial-cluster "ip-172-18-3-48.ec2.internal=https://172.18.3.48:2380"
    6. --initial-cluster-token "etcd-cluster-1"
    7. --initial-advertise-peer-urls https://172.18.3.48:2380
    8. --skip-hash-check=true

    Obtain the values for your cluster from the $/backup_files/etcd.conf file.

  4. Set required permissions and selinux context on the data directory:

    1. $ restorecon -Rv /var/lib/etcd/
  5. Restart the etcd pod by moving the pod manifest YAML file to the required directory:

    1. $ mv etcd.yaml /etc/origin/node/pods/.

Adding an etcd node

After you restore etcd, you can add more etcd nodes to the cluster. You can either add an etcd host by using an Ansible playbook or by manual steps.

Adding a new etcd host using Ansible

Procedure

  1. In the Ansible inventory file, create a new group named [new_etcd] and add the new host. Then, add the new_etcd group as a child of the [OSEv3] group:

    1. [OSEv3:children]
    2. masters
    3. nodes
    4. etcd
    5. new_etcd (1)
    6. ... [OUTPUT ABBREVIATED] ...
    7. [etcd]
    8. master-0.example.com
    9. master-1.example.com
    10. master-2.example.com
    11. [new_etcd] (1)
    12. etcd0.example.com (1)
    1Add these lines.
  2. From the host that installed OKD and hosts the Ansible inventory file, run the etcd scaleup playbook:

    1. $ ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/openshift-etcd/scaleup.yml
  3. After the playbook runs, modify the inventory file to reflect the current status by moving the new etcd host from the [new_etcd] group to the [etcd] group:

    1. [OSEv3:children]
    2. masters
    3. nodes
    4. etcd
    5. new_etcd
    6. ... [OUTPUT ABBREVIATED] ...
    7. [etcd]
    8. master-0.example.com
    9. master-1.example.com
    10. master-2.example.com
    11. etcd0.example.com
  4. If you use Flannel, modify the flanneld service configuration on every OKD host, located at /etc/sysconfig/flanneld, to include the new etcd host:

    1. FLANNEL_ETCD_ENDPOINTS=https://master-0.example.com:2379,https://master-1.example.com:2379,https://master-2.example.com:2379,https://etcd0.example.com:2379
  5. Restart the flanneld service:

    1. # systemctl restart flanneld.service

Manually adding a new etcd host

If you do not run etcd as static pods on master nodes, you might need to add another etcd host.

Procedure

Modify the current etcd cluster

To create the etcd certificates, run the openssl command, replacing the values with those from your environment.

  1. Create some environment variables:

    1. export NEW_ETCD_HOSTNAME="*etcd0.example.com*"
    2. export NEW_ETCD_IP="192.168.55.21"
    3. export CN=$NEW_ETCD_HOSTNAME
    4. export SAN="IP:${NEW_ETCD_IP}, DNS:${NEW_ETCD_HOSTNAME}"
    5. export PREFIX="/etc/etcd/generated_certs/etcd-$CN/"
    6. export OPENSSLCFG="/etc/etcd/ca/openssl.cnf"

    The custom openssl extensions used as etcdv3_ca* include the $SAN environment variable as subjectAltName. See /etc/etcd/ca/openssl.cnf for more information.

  2. Create the directory to store the configuration and certificates:

    1. # mkdir -p ${PREFIX}
  3. Create the server certificate request and sign it: (server.csr and server.crt)

    1. # openssl req -new -config ${OPENSSLCFG} \
    2. -keyout ${PREFIX}server.key \
    3. -out ${PREFIX}server.csr \
    4. -reqexts etcd_v3_req -batch -nodes \
    5. -subj /CN=$CN
    6. # openssl ca -name etcd_ca -config ${OPENSSLCFG} \
    7. -out ${PREFIX}server.crt \
    8. -in ${PREFIX}server.csr \
    9. -extensions etcd_v3_ca_server -batch
  4. Create the peer certificate request and sign it: (peer.csr and peer.crt)

    1. # openssl req -new -config ${OPENSSLCFG} \
    2. -keyout ${PREFIX}peer.key \
    3. -out ${PREFIX}peer.csr \
    4. -reqexts etcd_v3_req -batch -nodes \
    5. -subj /CN=$CN
    6. # openssl ca -name etcd_ca -config ${OPENSSLCFG} \
    7. -out ${PREFIX}peer.crt \
    8. -in ${PREFIX}peer.csr \
    9. -extensions etcd_v3_ca_peer -batch
  5. Copy the current etcd configuration and ca.crt files from the current node as examples to modify later:

    1. # cp /etc/etcd/etcd.conf ${PREFIX}
    2. # cp /etc/etcd/ca.crt ${PREFIX}
  6. While still on the surviving etcd host, add the new host to the cluster. To add additional etcd members to the cluster, you must first adjust the default localhost peer in the **peerURLs** value for the first member:

    1. Get the member ID for the first member using the member list command:

      1. # etcdctl --cert-file=/etc/etcd/peer.crt \
      2. --key-file=/etc/etcd/peer.key \
      3. --ca-file=/etc/etcd/ca.crt \
      4. --peers="https://172.18.1.18:2379,https://172.18.9.202:2379,https://172.18.0.75:2379" \ (1)
      5. member list
      1Ensure that you specify the URLs of only active etcd members in the —peers parameter value.
    2. Obtain the IP address where etcd listens for cluster peers:

      1. $ ss -l4n | grep 2380
    3. Update the value of **peerURLs** using the etcdctl member update command by passing the member ID and IP address obtained from the previous steps:

      1. # etcdctl --cert-file=/etc/etcd/peer.crt \
      2. --key-file=/etc/etcd/peer.key \
      3. --ca-file=/etc/etcd/ca.crt \
      4. --peers="https://172.18.1.18:2379,https://172.18.9.202:2379,https://172.18.0.75:2379" \
      5. member update 511b7fb6cc0001 https://172.18.1.18:2380
    4. Re-run the member list command and ensure the peer URLs no longer include localhost.

  7. Add the new host to the etcd cluster. Note that the new host is not yet configured, so the status stays as unstarted until the you configure the new host.

    You must add each member and bring it online one at a time. When you add each additional member to the cluster, you must adjust the peerURLs list for the current peers. The peerURLs list grows by one for each member added. The etcdctl member add command outputs the values that you must set in the etcd.conf file as you add each member, as described in the following instructions.

    1. # etcdctl -C https://${CURRENT_ETCD_HOST}:2379 \
    2. --ca-file=/etc/etcd/ca.crt \
    3. --cert-file=/etc/etcd/peer.crt \
    4. --key-file=/etc/etcd/peer.key member add ${NEW_ETCD_HOSTNAME} https://${NEW_ETCD_IP}:2380 (1)
    5. Added member named 10.3.9.222 with ID 4e1db163a21d7651 to cluster
    6. ETCD_NAME="<NEW_ETCD_HOSTNAME>"
    7. ETCD_INITIAL_CLUSTER="<NEW_ETCD_HOSTNAME>=https://<NEW_HOST_IP>:2380,<CLUSTERMEMBER1_NAME>=https:/<CLUSTERMEMBER2_IP>:2380,<CLUSTERMEMBER2_NAME>=https:/<CLUSTERMEMBER2_IP>:2380,<CLUSTERMEMBER3_NAME>=https:/<CLUSTERMEMBER3_IP>:2380"
    8. ETCD_INITIAL_CLUSTER_STATE="existing"
    1In this line, 10.3.9.222 is a label for the etcd member. You can specify the host name, IP address, or a simple name.
  8. Update the sample ${PREFIX}/etcd.conf file.

    1. Replace the following values with the values generated in the previous step:

      • ETCD_NAME

      • ETCD_INITIAL_CLUSTER

      • ETCD_INITIAL_CLUSTER_STATE

    2. Modify the following variables with the new host IP from the output of the previous step. You can use ${NEW_ETCD_IP} as the value.

      1. ETCD_LISTEN_PEER_URLS
      2. ETCD_LISTEN_CLIENT_URLS
      3. ETCD_INITIAL_ADVERTISE_PEER_URLS
      4. ETCD_ADVERTISE_CLIENT_URLS
    3. If you previously used the member system as an etcd node, you must overwrite the current values in the /etc/etcd/etcd.conf file.

    4. Check the file for syntax errors or missing IP addresses, otherwise the etcd service might fail:

      1. # vi ${PREFIX}/etcd.conf
  9. On the node that hosts the installation files, update the [etcd] hosts group in the /etc/ansible/hosts inventory file. Remove the old etcd hosts and add the new ones.

  10. Create a tgz file that contains the certificates, the sample configuration file, and the ca and copy it to the new host:

    1. # tar -czvf /etc/etcd/generated_certs/${CN}.tgz -C ${PREFIX} .
    2. # scp /etc/etcd/generated_certs/${CN}.tgz ${CN}:/tmp/
Modify the new etcd host
  1. Install iptables-services to provide iptables utilities to open the required ports for etcd:

    1. # yum install -y iptables-services
  2. Create the OS_FIREWALL_ALLOW firewall rules to allow etcd to communicate:

    • Port 2379/tcp for clients

    • Port 2380/tcp for peer communication

      1. # systemctl enable iptables.service --now
      2. # iptables -N OS_FIREWALL_ALLOW
      3. # iptables -t filter -I INPUT -j OS_FIREWALL_ALLOW
      4. # iptables -A OS_FIREWALL_ALLOW -p tcp -m state --state NEW -m tcp --dport 2379 -j ACCEPT
      5. # iptables -A OS_FIREWALL_ALLOW -p tcp -m state --state NEW -m tcp --dport 2380 -j ACCEPT
      6. # iptables-save | tee /etc/sysconfig/iptables

      In this example, a new chain OS_FIREWALL_ALLOW is created, which is the standard naming the OKD installer uses for firewall rules.

      If the environment is hosted in an IaaS environment, modify the security groups for the instance to allow incoming traffic to those ports as well.

  3. Install etcd:

    1. # yum install -y etcd

    Ensure version etcd-2.3.7-4.el7.x86_64 or greater is installed,

  4. Ensure the etcd service is not running by removing the etcd pod definition:

    1. # mkdir -p /etc/origin/node/pods-stopped
    2. # mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/
  5. Remove any etcd configuration and data:

    1. # rm -Rf /etc/etcd/*
    2. # rm -Rf /var/lib/etcd/*
  6. Extract the certificates and configuration files:

    1. # tar xzvf /tmp/etcd0.example.com.tgz -C /etc/etcd/
  7. Start etcd on the new host:

    1. # systemctl enable etcd --now
  8. Verify that the host is part of the cluster and the current cluster health:

    • If you use the v2 etcd api, run the following command:

      1. # etcdctl --cert-file=/etc/etcd/peer.crt \
      2. --key-file=/etc/etcd/peer.key \
      3. --ca-file=/etc/etcd/ca.crt \
      4. --peers="https://*master-0.example.com*:2379,\
      5. https://*master-1.example.com*:2379,\
      6. https://*master-2.example.com*:2379,\
      7. https://*etcd0.example.com*:2379"\
      8. cluster-health
      9. member 5ee217d19001 is healthy: got healthy result from https://192.168.55.12:2379
      10. member 2a529ba1840722c0 is healthy: got healthy result from https://192.168.55.8:2379
      11. member 8b8904727bf526a5 is healthy: got healthy result from https://192.168.55.21:2379
      12. member ed4f0efd277d7599 is healthy: got healthy result from https://192.168.55.13:2379
      13. cluster is healthy
    • If you use the v3 etcd api, run the following command:

      1. # ETCDCTL_API=3 etcdctl --cert="/etc/etcd/peer.crt" \
      2. --key=/etc/etcd/peer.key \
      3. --cacert="/etc/etcd/ca.crt" \
      4. --endpoints="https://*master-0.example.com*:2379,\
      5. https://*master-1.example.com*:2379,\
      6. https://*master-2.example.com*:2379,\
      7. https://*etcd0.example.com*:2379"\
      8. endpoint health
      9. https://master-0.example.com:2379 is healthy: successfully committed proposal: took = 5.011358ms
      10. https://master-1.example.com:2379 is healthy: successfully committed proposal: took = 1.305173ms
      11. https://master-2.example.com:2379 is healthy: successfully committed proposal: took = 1.388772ms
      12. https://etcd0.example.com:2379 is healthy: successfully committed proposal: took = 1.498829ms
Modify each OKD master
  1. Modify the master configuration in the etcClientInfo section of the /etc/origin/master/master-config.yaml file on every master. Add the new etcd host to the list of the etcd servers OKD uses to store the data, and remove any failed etcd hosts:

    1. etcdClientInfo:
    2. ca: master.etcd-ca.crt
    3. certFile: master.etcd-client.crt
    4. keyFile: master.etcd-client.key
    5. urls:
    6. - https://master-0.example.com:2379
    7. - https://master-1.example.com:2379
    8. - https://master-2.example.com:2379
    9. - https://etcd0.example.com:2379
  2. Restart the master API service:

    • On every master:

      1. # master-restart api
      2. # master-restart controllers

      The number of etcd nodes must be odd, so you must add at least two hosts.

  3. If you use Flannel, modify the flanneld service configuration located at /etc/sysconfig/flanneld on every OKD host to include the new etcd host:

    1. FLANNEL_ETCD_ENDPOINTS=https://master-0.example.com:2379,https://master-1.example.com:2379,https://master-2.example.com:2379,https://etcd0.example.com:2379
  4. Restart the flanneld service:

    1. # systemctl restart flanneld.service

Bringing OKD services back online

After you finish your changes, bring OKD back online.

Procedure

  1. On each OKD master, restore your master and node configuration from backup and enable and restart all relevant services:

    1. # cp ${MYBACKUPDIR}/etc/origin/node/pods/* /etc/origin/node/pods/
    2. # cp ${MYBACKUPDIR}/etc/origin/master/master.env /etc/origin/master/master.env
    3. # cp ${MYBACKUPDIR}/etc/origin/master/master-config.yaml.<timestamp> /etc/origin/master/master-config.yaml
    4. # cp ${MYBACKUPDIR}/etc/origin/node/node-config.yaml.<timestamp> /etc/origin/node/node-config.yaml
    5. # cp ${MYBACKUPDIR}/etc/origin/master/scheduler.json.<timestamp> /etc/origin/master/scheduler.json
    6. # master-restart api
    7. # master-restart controllers
  2. On each OKD node, update the node configuration maps as needed, and enable and restart the atomic-openshift-node service:

    1. # cp /etc/origin/node/node-config.yaml.<timestamp> /etc/origin/node/node-config.yaml
    2. # systemctl enable atomic-openshift-node
    3. # systemctl start atomic-openshift-node

Restoring a project

To restore a project, create the new project, then restore any exported files by running oc create -f pods.json. However, restoring a project from scratch requires a specific order because some objects depend on others. For example, you must create the configmaps before you create any pods.

Procedure

  1. If the project was exported as a single file, import it by running the following commands:

    1. $ oc new-project <projectname>
    2. $ oc create -f project.yaml
    3. $ oc create -f secret.yaml
    4. $ oc create -f serviceaccount.yaml
    5. $ oc create -f pvc.yaml
    6. $ oc create -f rolebindings.yaml

    Some resources, such as pods and default service accounts, can fail to be created.

Restoring application data

You can restore application data by using the oc rsync command, assuming rsync is installed within the container image. The Red Hat rhel7 base image contains rsync. Therefore, all images that are based on rhel7 contain it as well. See Troubleshooting and Debugging CLI Operations - rsync.

This is a generic restoration of application data and does not take into account application-specific backup procedures, for example, special export and import procedures for database systems.

Other means of restoration might exist depending on the type of the persistent volume you use, for example, Cinder, NFS, or Gluster.

Procedure

Example of restoring a Jenkins deployment’s application data

  1. Verify the backup:

    1. $ ls -la /tmp/jenkins-backup/
    2. total 8
    3. drwxrwxr-x. 3 user user 20 Sep 6 11:14 .
    4. drwxrwxrwt. 17 root root 4096 Sep 6 11:16 ..
    5. drwxrwsrwx. 12 user user 4096 Sep 6 11:14 jenkins
  2. Use the oc rsync tool to copy the data into the running pod:

    1. $ oc rsync /tmp/jenkins-backup/jenkins jenkins-1-37nux:/var/lib

    Depending on the application, you may be required to restart the application.

  3. Optionally, restart the application with new data:

    1. $ oc delete pod jenkins-1-37nux

    Alternatively, you can scale down the deployment to 0, and then up again:

    1. $ oc scale --replicas=0 dc/jenkins
    2. $ oc scale --replicas=1 dc/jenkins

Restoring Persistent Volume Claims

This topic describes two methods for restoring data. The first involves deleting the file, then placing the file back in the expected location. The second example shows migrating persistent volume claims. The migration would occur in the event that the storage needs to be moved or in a disaster scenario when the backend storage no longer exists.

Check with the restore procedures for the specific application on any steps required to restore data to the application.

Restoring files to an existing PVC

Procedure

  1. Delete the file:

    1. $ oc rsh demo-2-fxx6d
    2. sh-4.2$ ls */opt/app-root/src/uploaded/*
    3. lost+found ocp_sop.txt
    4. sh-4.2$ *rm -rf /opt/app-root/src/uploaded/ocp_sop.txt*
    5. sh-4.2$ *ls /opt/app-root/src/uploaded/*
    6. lost+found
  2. Replace the file from the server that contains the rsync backup of the files that were in the pvc:

    1. $ oc rsync uploaded demo-2-fxx6d:/opt/app-root/src/
  3. Validate that the file is back on the pod by using oc rsh to connect to the pod and view the contents of the directory:

    1. $ oc rsh demo-2-fxx6d
    2. sh-4.2$ *ls /opt/app-root/src/uploaded/*
    3. lost+found ocp_sop.txt

Restoring data to a new PVC

The following steps assume that a new pvc has been created.

Procedure

  1. Overwrite the currently defined claim-name:

    1. $ oc volume dc/demo --add --name=persistent-volume \
    2. --type=persistentVolumeClaim --claim-name=filestore \ --mount-path=/opt/app-root/src/uploaded --overwrite
  2. Validate that the pod is using the new PVC:

    1. $ oc describe dc/demo
    2. Name: demo
    3. Namespace: test
    4. Created: 3 hours ago
    5. Labels: app=demo
    6. Annotations: openshift.io/generated-by=OpenShiftNewApp
    7. Latest Version: 3
    8. Selector: app=demo,deploymentconfig=demo
    9. Replicas: 1
    10. Triggers: Config, Image(demo@latest, auto=true)
    11. Strategy: Rolling
    12. Template:
    13. Labels: app=demo
    14. deploymentconfig=demo
    15. Annotations: openshift.io/container.demo.image.entrypoint=["container-entrypoint","/bin/sh","-c","$STI_SCRIPTS_PATH/usage"]
    16. openshift.io/generated-by=OpenShiftNewApp
    17. Containers:
    18. demo:
    19. Image: docker-registry.default.svc:5000/test/demo@sha256:0a9f2487a0d95d51511e49d20dc9ff6f350436f935968b0c83fcb98a7a8c381a
    20. Port: 8080/TCP
    21. Volume Mounts:
    22. /opt/app-root/src/uploaded from persistent-volume (rw)
    23. Environment Variables: <none>
    24. Volumes:
    25. persistent-volume:
    26. Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    27. *ClaimName: filestore*
    28. ReadOnly: false
    29. ...omitted...
  3. Now that the deployement configuration uses the new pvc, run oc rsync to place the files onto the new pvc:

    1. $ oc rsync uploaded demo-3-2b8gs:/opt/app-root/src/
    2. sending incremental file list
    3. uploaded/
    4. uploaded/ocp_sop.txt
    5. uploaded/lost+found/
    6. sent 181 bytes received 39 bytes 146.67 bytes/sec
    7. total size is 32 speedup is 0.15
  4. Validate that the file is back on the pod by using oc rsh to connect to the pod and view the contents of the directory:

    1. $ oc rsh demo-3-2b8gs
    2. sh-4.2$ ls /opt/app-root/src/uploaded/
    3. lost+found ocp_sop.txt