openshift 4: difference between nfs and block storage - openshift

what is the difference between block and nfs storage in openfhist ?
why use block or nfs ? what is advantage of these technologies
thanks in advance

what is the difference between block and nfs storage in openfhist ?
As a view of OpenShift, it's just a kind of the persistent storage backends.
why use block or nfs ? what is advantage of these technologies
Just you should appropriately use each storage type for each component. It's the reason why you should use block or nfs for each component in OpenShift.
Refer Optimizing storage for more details.
For example, usually we do not use NFS for Database storage in production env due to POSIX compliant and performance. Each storage has its own use like this.

Related

Should I use k8s statefulsets directly or mysql-operator to deploy master-slave mysql cluster?

So I want to deploy a master-slaves MySQL cluster in k8s. I found 2 ways that seem popular:
The first one is to use statefulsets directly from k8s official document: https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/
The second one is to use operator, i.e. https://github.com/oracle/mysql-operator
Which way is most commonly used?
Also, in statefulsets, if my MySQL master dies, will k8s automatically promote the slave to be the master?
Lastly, when my logic backend app performs an operation (CRUD) to MySQL cluster, how does k8s know which pod to route to, i.e. write operation can only be sent to master while read is sent to all?
Users can deploy and maintain a set of highly available MySQL services in k8s based on StatefulSets, the process is relatively complex. This process requires users to familiarize themselves with various k8s resource objects, learn many MySQL operation details and maintain a set of complex management scripts. Kubernetes Operators are designed to reduce the threshold for deploying complex applications on k8s.
Operator hides the orchestration details of complex applications and greatly reduces the threshold to use them in k8s. If you need to deploy other complex applications, we recommend that you use the Operator.
Speaking about master election while using StatefulSet.
Electing potential slave to be a master is not an automatic process - you have to configure this manually using Xtrabackup - here is more information - setting_up_replication.
Take a look: cloning-existing-data, starting-replication, mysql-statefulset-operator.
Useful tools: vitess for better MySQL networking management and percona-xtradb-cluster that provides superior performance, scalability and instrumentation.

Is storage in Openshift Online free tier actually persistent?

I'm trying to migrate an Openshift v2 application to v3. I'm really struggling to understand the documentation. In the section on persistent volumes, it says the following:
EmptyDir has the same lifecycle as the pod:
EmptyDir volumes survive container crashes/restarts.
EmptyDir volumes are deleted when the pod is deleted.
I cannot understand what this means. I have added storage to my app using the Web Console, which allowed me to add 1 GB of persistent storage and give it to a particular mountpoint. I don't know if this is an "EmptyDir" volume or not (I think it isn't, but in that case why the warning in the persistent volumes section?). Now, every time I rebuild the application, a new pod is created (if I understand this correctly). So far my data has persisted when this happens. Does this warning mean it can suddenly be wiped out? Or is persistent storage persistent?
When you claim a persistent volume, you are not usually using an EmptyDir volume type, so that isn't relevant. EmptyDir is a special volume type that is managed a bit differently that would normally only be needed if you want to share some temporary file system space between different containers in the same pod.
In short, the persistent storage is indeed 'persistent'. You could see the difference by a simple experiment of creating a mysql with "non-persistent" vs "persistent".
The openshift architecture is built on Amazon infrastructure. Please check AWS EBS volume which is backbone of Openshift persistent storage -
https://aws.amazon.com/ebs/getting-started/
EDIT
Think it like that
EBS Volume -- ATTACHED TO --- pod ---- WHICH CONTAINS --- Containers
What document means to say that, if you destroy the POD (think of a machine), the EBS volume will be wiped out and available again as an unattached resource. Its lifecycle limited by pod. However, a POD can contain multiple containers (say JVM) and each container can share the EBS volume (think of a hard disk), but killing a container does not affect the EBS lifecycle.

Is it recommended to run clustered database with Kubernetes in production environment?

Is it reasonable to use Kubernetes for a clustered database such as MySQL in production environment?
There are example configurations such as mysql galera example. However, most examples do not make use of persistent volumes. As far as I've understood persistent volumes must reside on some shared file system as defined here Kubernetes types of persistent volumes. A shared file system will not guarantee that the database files of the pod will be local to the machine hosting the pod. It will be accessed over network which is rather slow. Moreover, there are issues with MySQL and NFS, for example.
This might be acceptable for a test environment. However, what should I do in a production environment? Is it better to run the database cluster outside Kubernetes and run only application servers with Kubernetes?
The Kubernetes project introduced PetSets, a new pod management abstraction, intended to run stateful applications. It is an alpha feature at present (as of version 1.4) and moving rapidly. A list of the various issues as we move to beta are listed here. Quoting from the section on when to use petsets:
A PetSet ensures that a specified number of "pets" with unique identities are running at any given time. The identity of a Pet is comprised of:
a stable hostname, available in DNS
an ordinal index
stable storage: linked to the ordinal & hostname
In addition to the above, it can be coupled with several other features which help one deploy clustered stateful applications and manage them. Coupled with dynamic volume provisioning for example, it can be used to provision storage automatically.
There are several YAML configuration files available (such as the ones you referenced) using ReplicaSets and Deployments for MySQL and other databases which may be run in production and are probably being run that way as well. However, PetSets are expected to make it a lot easier to run these types of workloads, while supporting upgrades, maintenance, scaling and so on.
You can find some examples of distributed databases with petsets here.
The advantage of provisioning persistent volumes which are networked and non-local (such as GlusterFS) is realized at scale. However, for relatively small clusters, there is a proposal to allow for local storage persistent volumes in the future.

Is it recommended to use GCE as a web server?

I'm new to the whole cloud concept.
I have set up a Windows VM with GCE, remote desktopped into it, installed Apache HTTPD and set the firewall rules, turning this Google GCE into a web server. I intend to install Perl, which is my primary programming language and isn't supported in App Engine.
I am looking for an alternative to my current hosting solution for better uptime and availability, or at least a fall-back service.
Is it recommended to use GCE in this way or am I barking up the wrong tree?
GCE is a very general solution, you can use your VM for whatever purpose you want. In particular GCE is recommended for all workloads that do not fit in the rather strict limitations of App Engine.
Having said that, web hosting was probably the first and main use case for GCE when it was being implemented. On top of having a single VM serving your traffic you can trivially scale your solution up by using load balancers and/or autoscaling. On top of that you can use a managed DB if your web server needs storage, etc. So the answer is, yes, GCE is definitely designed to be used as a web server.

transfer data from low version (2.1) to higher version (4.0) in couchbase

I am running a couchbase cluster (v2.1). Now I have a couchbase cluster (v4.0) provisioned. I want to transfer data from the 2.1 cluster to the 4.0 cluster. Can I just simply use the XDCR through the web console to do that? That is I replicate the data from the v2.1 cluster to the v4.0 cluster.
Any risk that I might lose the data in the v2.1 cluster?
Thanks for the hints.
Yes, you can simply use XDCR to replicate the data to the new cluster. It is robust and is designed to replicate data safely. Note that XDCR uses some resources, so make sure your source cluster has enough CPU and memory headroom. Couchbase best practices recommend approximately 1 core per replication steam and at most 80% of RAM allocates to Couchbase.