Nginx Welcome Page
0

Introduction

Heptio Ark is a handy backup software for Kubernetes clusters that compresses and backs up Kubernetes objects to object storage. It additionally takes snapshots of your cluster’s Persistent Volumes utilizing your cloud supplier’s block storage snapshot options, and might then restore your cluster’s objects and Persistent Volumes to a earlier state.

StackPointCloud’s DigitalOcean Ark Plugin means that you can use DigitalOcean block storage to snapshot your Persistent Volumes, and Areas to again up your Kubernetes objects. When working a Kubernetes cluster on DigitalOcean, this lets you rapidly again up your cluster’s state and restore it ought to catastrophe strike.

On this tutorial we’ll arrange and configure the Ark shopper on a neighborhood machine, and deploy the Ark server into our Kubernetes cluster. We’ll then deploy a pattern Nginx app that makes use of a Persistent Quantity for logging, and simulate a catastrophe restoration situation.

Conditions

Earlier than you start this tutorial, it is best to have the next obtainable to you:

In your native laptop:

In your DigitalOcean account:

  • A DigitalOcean Kubernetes cluster, or a Kubernetes cluster (model 1.7.5 or later) on DigitalOcean Droplets
  • A DNS server working inside your cluster. If you’re utilizing DigitalOcean Kubernetes, that is working by default. To be taught extra about configuring a Kubernetes DNS service, seek the advice of Customizing DNS Service from the official Kuberentes documentation.
  • A DigitalOcean Area that can retailer your backed-up Kubernetes objects. To discover ways to create a Area, seek the advice of the Areas product documentation.
  • An entry key pair in your DigitalOcean Area. To discover ways to create a set of entry keys, seek the advice of Learn how to Handle Administrative Entry to Areas.
  • A private entry token to be used with the DigitalOcean API. To discover ways to create a private entry token, seek the advice of Learn how to Create a Private Entry Token.

Upon getting all of this arrange, you are prepared to start with this information.

Step 1 — Putting in the Ark Shopper

The Heptio Ark backup software consists of a shopper put in in your native laptop and a server that runs in your Kubernetes cluster. To start, we’ll set up the native Ark shopper.

In your internet browser, navigate to the Ark GitHub repo releases web page, discover the most recent launch similar to your OS and system structure, and replica the hyperlink deal with. For the needs of this information, we’ll use an Ubuntu 18.04 server on an x86-64 (or AMD64) processor as our native machine.

Then, from the command line in your native laptop, navigate to the short-term /tmp listing and cd into it:

Use wget and the hyperlink you copied earlier to obtain the discharge tarball:

  • wget https://link_copied_from_release_page

As soon as the obtain completes, extract the tarball utilizing tar (be aware the filename could differ relying on the present launch model and your OS):

  • tar -xvzf ark-v0.9.6-linux-amd64.tar.gz

The /tmp listing ought to now comprise the extracted ark binary in addition to the tarball you simply downloaded.

Confirm which you could run the ark shopper by executing the binary:

You need to see the next assist output:

Output

Heptio Ark is a software for managing catastrophe restoration, particularly for Kubernetes cluster assets. It supplies a easy, configurable, and operationally strong technique to again up your utility state and related knowledge. For those who're acquainted with kubectl, Ark helps the same mannequin, permitting you to execute instructions similar to 'ark get backup' and 'ark create schedule'. The identical operations can be carried out as 'ark backup get' and 'ark schedule create'. Utilization: ark [command] Accessible Instructions: backup Work with backups shopper Ark shopper associated instructions completion Output shell completion code for the required shell (bash or zsh) create Create ark assets delete Delete ark assets describe Describe ark assets get Get ark assets assist Assist about any command plugin Work with plugins restic Work with restic restore Work with restores schedule Work with schedules server Run the ark server model Print the ark model and related picture . . .

At this level it is best to transfer the ark executable out of the short-term /tmp listing and add it to your PATH. So as to add it to your PATH on an Ubuntu system, merely copy it to /usr/native/bin:

  • sudo mv ark /usr/native/bin/ark

You are now able to configure the Ark server and deploy it to your Kubernetes cluster.

Step 2 — Putting in and Configuring the Ark Server

Earlier than we deploy Ark into our Kubernetes cluster, we'll first create Ark's prerequisite objects. Ark's conditions include:

  • A heptio-ark Namespace

  • The ark Service Account

  • Function-based entry management (RBAC) guidelines to grant permissions to the ark Service Account

  • Customized Sources (CRDs) for the Ark-specific assets: Backup, Schedule, Restore, Config

A YAML file containing the specs for the above Kubernetes objects may be discovered within the official Ark Git repository. Whereas nonetheless within the /tmp listing, obtain the Ark repo utilizing git:

  • git clone https://github.com/heptio/ark.git

As soon as downloaded, navigate into the ark listing:

The prerequisite assets listed above may be discovered within the examples/frequent/00-prereqs.yaml YAML file. We'll create these assets in our Kubernetes cluster through the use of kubectl apply and passing within the file:

  • kubectl apply -f examples/frequent/00-prereqs.yaml

You need to see the next output:

Output

customresourcedefinition.apiextensions.k8s.io/backups.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/schedules.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/restores.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/configs.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/downloadrequests.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/deletebackuprequests.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/podvolumebackups.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/podvolumerestores.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/resticrepositories.ark.heptio.com created customresourcedefinition.apiextensions.k8s.io/backupstoragelocations.ark.heptio.com created namespace/heptio-ark created serviceaccount/ark created clusterrolebinding.rbac.authorization.k8s.io/ark created

Now that we have created the mandatory Ark Kubernetes objects in our cluster, we will obtain and set up the Ark DigitalOcean Plugin, which is able to enable us to make use of DigitalOcean Areas as a backupStorageProvider (for Kubernetes objects), and DigitalOcean Block Storage as a persistentVolumeProvider (for Persistent Quantity backups).

Transfer again out of the ark listing and fetch the plugin from StackPointCloud's repo utilizing git:

  • cd ..
  • git clone https://github.com/StackPointCloud/ark-plugin-digitalocean.git

Transfer into the plugin listing:

  • cd ark-plugin-digitalocean

We'll now save the entry keys for our DigitalOcean Area as a Kubernetes Secret. First, open up the examples/credentials-ark file utilizing your favourite editor:

  • nano examples/credentials-ark

Exchange <AWS_ACCESS_KEY_ID> and <AWS_SECRET_ACCESS_KEY> along with your Areas entry key and secret key:

examples/credentials-ark

[default]
aws_access_key_id=your_spaces_access_key_here
aws_secret_access_key=your_spaces_secret_key_here

Save and shut the file.

Now, create the cloud-credentials Secret utilizing kubectl, inserting your Private Entry Token utilizing the digitalocean_token knowledge merchandise:

  • kubectl create secret generic cloud-credentials
  • --namespace heptio-ark
  • --from-file cloud=examples/credentials-ark
  • --from-literal digitalocean_token=your_personal_access_token

You need to see the next output:

Output

secret/cloud-credentials created

To verify that the cloud-credentials Secret was created efficiently, you may describe it utilizing kubectl:

  • kubectl describe secrets and techniques/cloud-credentials --namespace heptio-ark

You need to see the next output describing the cloud-credentials secret:

Output

Identify: cloud-credentials Namespace: heptio-ark Labels: <none> Annotations: <none> Kind: Opaque Information ==== cloud: 115 bytes digitalocean_token: 64 bytes

We are able to now transfer on to creating an Ark Config object named default. To do that, we'll edit a YAML configuration file after which create the item in our Kubernetes cluster.

Open examples/10-ark-config.yaml in your favourite editor:

  • nano examples/10-ark-config.yaml

Insert your Area's title and area within the highlighted fields:

examples/10-ark-config.yaml

---
apiVersion: ark.heptio.com/v1
sort: Config
metadata:
  namespace: heptio-ark
  title: default
persistentVolumeProvider:
  title: digitalocean
backupStorageProvider:
  title: aws
  bucket: space_name_here
  config:
    area: space_region_here
    s3ForcePathStyle: "true"
    s3Url: https://space_region_here.digitaloceanspaces.com
backupSyncPeriod: 30m
gcSyncPeriod: 30m
scheduleSyncPeriod: 1m
restoreOnlyMode: false

persistentVolumeProvider units DigitalOcean Block Storage because the the supplier for Persistent Quantity backups. These might be Block Storage Quantity Snapshots.

backupStorageProvider units DigitalOcean Areas because the supplier for Kubernetes object backups. Ark will create a tarball of all of your Kubernetes objects (or some, relying on the way you execute it), and add this tarball to Areas.

Once you're achieved, save and shut the file.

Create the item in your cluster utilizing kubectl apply:

  • kubectl apply -f examples/10-ark-config.yaml

You need to see the next output:

Output

config.ark.heptio.com/default created

At this level, we have completed configuring the Ark server and might create its Kubernetes deployment, discovered within the examples/20-deployment.yaml configuration file. Let's take a fast take a look at this file:

  • cat examples/20-deployment.yaml

You need to see the next textual content:

examples/20-deployment.yaml

---
apiVersion: apps/v1beta1
sort: Deployment
metadata:
  namespace: heptio-ark
  title: ark
spec:
  replicas: 1
  template:
    metadata:
      labels:
        part: ark
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "8085"
        prometheus.io/path: "/metrics"
    spec:
      restartPolicy: At all times
      serviceAccountName: ark
      containers:
        - title: ark
          picture: gcr.io/heptio-images/ark:newest
          command:
            - /ark
          args:
            - server
          volumeMounts:
            - title: cloud-credentials
              mountPath: /credentials
            - title: plugins
              mountPath: /plugins
            - title: scratch
              mountPath: /scratch
          env:
            - title: AWS_SHARED_CREDENTIALS_FILE
              worth: /credentials/cloud
            - title: ARK_SCRATCH_DIR
              worth: /scratch
            - title: DIGITALOCEAN_TOKEN
              valueFrom:
                secretKeyRef:
                  key: digitalocean_token
                  title: cloud-credentials
      volumes:
        - title: cloud-credentials
          secret:
            secretName: cloud-credentials
        - title: plugins
          emptyDir: {}
        - title: scratch
          emptyDir: {}

We observe right here that we're making a Deployment referred to as ark that consists of a single duplicate of the gcr.io/heptio-images/ark:newest container. The Pod is configured utilizing the cloud-credentials secret we created earlier.

Create the Deployment utilizing kubectl apply:

  • kubectl apply -f examples/20-deployment.yaml

You need to see the next output:

Output

deployment.apps/ark created

We are able to double verify that the Deployment has been efficiently created utilizing kubectl get on the heptio-ark Namespace :

  • kubectl get deployments --namespace=heptio-ark

You need to see the next output:

Output

NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE ark 1 1 1 0 8m

The Ark server Pod could not begin appropriately till you put in the Ark DigitalOcean plugin. To put in the ark-blockstore-digitalocean plugin, use the ark shopper we put in earlier:

  • ark plugin add quay.io/stackpoint/ark-blockstore-digitalocean:newest

You possibly can specify the kubeconfig to make use of with the --kubeconfig flag. For those who do not use this flag, ark will verify the KUBECONFIG setting variable after which fall again to the kubectl default (~/.kube/config).

At this level Ark is working and absolutely configured, and able to again up and restore your Kubernetes cluster objects and Persistent Volumes to DigitalOcean Areas and Block Storage.

Within the subsequent part, we'll run a fast take a look at to make it possible for the backup and restore performance works as anticipated.

Step 3 — Testing Backup and Restore Process

Now that we have efficiently put in and configured Ark, we will create a take a look at Nginx Deployment and Persistent Quantity, and run by a backup and restore drill to make sure that every part is working correctly.

The ark-plugin-digitalocean repository incorporates a pattern Nginx deployment referred to as nginx-pv.yaml.

Let's take a fast look:

  • cat examples/nginx-pv.yaml

You need to see the next textual content:

Output

--- sort: PersistentVolumeClaim apiVersion: v1 metadata: title: nginx-logs namespace: nginx-example labels: app: nginx spec: storageClassName: do-block-storage accessModes: - ReadWriteOnce assets: requests: storage: 5Gi --- apiVersion: apps/v1beta1 sort: Deployment metadata: title: nginx-deployment namespace: nginx-example spec: replicas: 1 template: metadata: labels: app: nginx spec: volumes: - title: nginx-logs persistentVolumeClaim: claimName: nginx-logs containers: - picture: nginx:1.7.9 title: nginx ports: - containerPort: 80 volumeMounts: - mountPath: "/var/log/nginx" title: nginx-logs readOnly: false --- apiVersion: v1 sort: Service metadata: labels: app: nginx title: my-nginx namespace: nginx-example spec: ports: - port: 80 targetPort: 80 selector: app: nginx kind: LoadBalancer

On this file, we observe specs for:

  • An Nginx Deployment consisting of a single duplicate of the nginx:1.7.9 container picture
  • A 5Gi Persistent Quantity Declare (referred to as nginx-logs), utilizing the do-block-storage StorageClass
  • A LoadBalancer Service that exposes port 80

Create the deployment utilizing kubectl apply:

  • kubectl apply -f examples/nginx-pv.yml

You need to see the next output:

Output

namespace/nginx-example created persistentvolumeclaim/nginx-logs created deployment.apps/nginx-deployment created service/my-nginx created

Examine that the Deployment succeeded:

  • kubectl get deployments --namespace=nginx-example

You need to see the next output:

Output

NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE nginx-deployment 1 1 1 1 1h

As soon as Accessible reaches 1, fetch the Nginx load balancer’s exterior IP utilizing kubectl get:

  • kubectl get providers --namespace=nginx-example

You need to see each the inner CLUSTER-IP and EXTERNAL-IP for the my-nginx Service:

Output

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-nginx LoadBalancer 10.32.27.0 203.0.113.0 80:30754/TCP 3m

Notice the EXTERNAL-IP and navigate to it utilizing your internet browser.

You need to see the next NGINX welcome web page:

Nginx Welcome Page

This means that your Nginx Deployment and Service are up and working.

Earlier than we simulate our catastrophe situation, let’s first verify the Nginx entry logs (saved on a Persistent Quantity hooked up to the Nginx Pod):

Fetch the Pod’s title utilizing kubectl get:

  • kubectl get pods --namespace nginx-example

Output

NAME READY STATUS RESTARTS AGE nginx-deployment-77d8f78fcb-zt4wr 1/1 Operating 0 29m

Now, exec into the working Nginx container to get a shell inside it:

  • kubectl exec -it nginx-deployment-77d8f78fcb-zt4wr --namespace nginx-example -- /bin/bash

As soon as contained in the Nginx container, cat the Nginx entry logs:

  • cat /var/log/nginx/entry.log

You need to see some Nginx entry entries:

Output

10.244.17.1 - - [01/Oct/2018:21:47:01 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/203.0.113.11 Safari/537.36" "-" 10.244.17.1 - - [01/Oct/2018:21:47:01 +0000] "GET /favicon.ico HTTP/1.1" 404 570 "http://203.0.113.0/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/203.0.113.11 Safari/537.36" "-"

Notice these down (particularly the timestamps), as we'll use them to verify the success of the restore process.

We are able to now carry out the backup process to repeat all nginx Kubernetes objects to Areas and take a Snapshot of the Persistent Quantity we created when deploying Nginx.

We'll create a backup referred to as nginx-backup utilizing the ark shopper:

  • ark backup create nginx-backup --selector app=nginx

The --selector app=nginx instructs the Ark server to solely again up Kubernetes objects with the app=nginx Label Selector.

You need to see the next output:

Output

Backup request "nginx-backup" submitted efficiently. Run `ark backup describe nginx-backup` for extra particulars.

Operating ark backup describe nginx-backup ought to present the next output after a brief delay:

Output

Identify: nginx-backup Namespace: heptio-ark Labels: <none> Annotations: <none> Part: Accomplished Namespaces: Included: * Excluded: <none> Sources: Included: * Excluded: <none> Cluster-scoped: auto Label selector: app=nginx Snapshot PVs: auto TTL: 720h0m0s Hooks: <none> Backup Format Model: 1 Began: 2018-09-26 00:14:30 -0400 EDT Accomplished: 2018-09-26 00:14:34 -0400 EDT Expiration: 2018-10-26 00:14:30 -0400 EDT Validation errors: <none> Persistent Volumes: pvc-e4862eac-c2d2-11e8-920b-92c754237aeb: Snapshot ID: 2eb66366-c2d3-11e8-963b-0a58ac14428b Kind: ext4 Availability Zone: IOPS: <N/A>

This output signifies that nginx-backup accomplished efficiently.

From the DigitalOcean Cloud Management Panel, navigate to the Area containing your Kubernetes backup information.

You need to see a brand new listing referred to as nginx-backup containing the Ark backup information.

Utilizing the left-hand navigation bar, go to Photos after which Snapshots. Inside Snapshots, navigate to Volumes. You need to see a Snapshot similar to the PVC listed within the above output.

We are able to now take a look at the restore process.

Let's first delete the nginx-example Namespace. This can delete every part within the Namespace, together with the Load Balancer and Persistent Quantity:

  • kubectl delete namespace nginx-example

Confirm which you could not entry Nginx on the Load Balancer endpoint, and that the nginx-example Deployment is not working:

  • kubectl get deployments --namespace=nginx-example

Output

No assets discovered.

We are able to now carry out the restore process, as soon as once more utilizing the ark shopper:

  • ark restore create --from-backup nginx-backup

Right here we use create to create an Ark Restore object from the nginx-backup object.

You need to see the next output:

Output

  • Restore request "nginx-backup-20180926143828" submitted efficiently.
  • Run `ark restore describe nginx-backup-20180926143828` for extra particulars.

Examine the standing of the restored Deployment:

  • kubectl get deployments --namespace=nginx-example

Output

NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE nginx-deployment 1 1 1 1 1m

Examine for the creation of a Persistent Quantity:

  • kubectl get pvc --namespace=nginx-example

Output

NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE nginx-logs Certain pvc-e4862eac-c2d2-11e8-920b-92c754237aeb 5Gi RWO do-block-storage 3m

Navigate to the Nginx Service’s exterior IP as soon as once more to verify that Nginx is up and working.

Lastly, verify the logs on the restored Persistent Quantity to verify that the log historical past has been preserved post-restore.

To do that, as soon as once more fetch the Pod’s title utilizing kubectl get:

  • kubectl get pods --namespace nginx-example

Output

NAME READY STATUS RESTARTS AGE nginx-deployment-77d8f78fcb-zt4wr 1/1 Operating 0 29m

Then exec into it:

  • kubectl exec -it nginx-deployment-77d8f78fcb-zt4wr --namespace nginx-example -- /bin/bash

As soon as contained in the Nginx container, cat the Nginx entry logs:

  • cat /var/log/nginx/entry.log

Output

10.244.17.1 - - [01/Oct/2018:21:47:01 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/203.0.113.11 Safari/537.36" "-" 10.244.17.1 - - [01/Oct/2018:21:47:01 +0000] "GET /favicon.ico HTTP/1.1" 404 570 "http://203.0.113.0/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/203.0.113.11 Safari/537.36" "-"

You need to see the identical pre-backup entry makes an attempt (be aware the timestamps), confirming that the Persistent Quantity restore was profitable. Notice that there could also be further makes an attempt within the logs for those who visited the Nginx touchdown web page after you carried out the restore.

At this level, we have efficiently backed up our Kubernetes objects to DigitalOcean Areas, and our Persistent Volumes utilizing Block Storage Quantity Snapshots. We simulated a catastrophe situation, and restored service to the take a look at Nginx utility.

Conclusion

On this information we put in and configured the Ark Kubernetes backup software on a DigitalOcean-based Kubernetes cluster. We configured the software to again up Kubernetes objects to DigitalOcean Areas, and again up Persistent Volumes utilizing Block Storage Quantity Snapshots.

Ark can be used to schedule common backups of your Kubernetes cluster. To do that, you should use the ark schedule command. It can be used emigrate assets from one cluster to a different. To be taught extra about these two use instances, seek the advice of the official Ark documentation.

To be taught extra about DigitalOcean Areas, seek the advice of the official Areas documentation. To be taught extra about Block Storage Volumes, seek the advice of the Block Storage Quantity documentation.

This tutorial builds on the README present in StackPointCloud's ark-plugin-digitalocean GitHub repo.

Samsung’s obscenely costly 85-inch 8K TV ships later this month

Previous article

Linux vdir Command Tutorial for Freshmen (eight Examples)

Next article

You may also like

Comments

Leave a Reply

More in DigitalOcean