Posts

Showing posts from November, 2020

Sample codes to create different storage types in Kubernetes

Kubernetes Types of Storage. In my previous article I talk about sample codes for kubernetes persistent storage using NFS, today I have add other storage types that can be use in Kubernetes and sample codes. You can use kubectl get storageclass to get list of storage class you already have configured. ###### Fast speed storage classification ####### apiVersion: storage.k8s.io/v1 kind: StorageClass metadata:   name: fast provisioner: kubernetes.io/gce-pd parameters:   type: pd-ssd ##### Low speed storage classification ###### apiVersion: storage.k8s.io/v1 kind: StorageClass metadata:   name: slow provisioner: kubernetes.io/gce-pd parameters:   type: pd-standard   ###### Dynamic provisioning persistanct storage claim ###### apiVersion: v1 kind: PersistentVolumeClaim metadata:   name: claim1 spec:   accessModes:     - ReadWriteOnce   storageClassName: fast   resources:     requests:       s...

Sample code to attach persistent volume claim in kubernetes

Sample code to attach persistent volume claim in kubernetes This code will add 500Mi to be use as persistent volume claim PVC. apiVersion: v1 kind: PersistentVolumeClaim metadata:   name: pvc1 spec:   storageClassName: managed-nfs-storage   accessModes:     - ReadWriteMany   resources:     requests:       storage: 500Mi

Persistent Storage NFS code for Kubernetes

 Persistent Storage NFS code for Kubernetes: This is a sample you should modify it based on your environment. kind: Deployment apiVersion: apps/v1 metadata:   name: nfs-client-provisioner spec:   selector:     matchLabels:       app: nfs-client-provisioner   replicas: 1   strategy:     type: Recreate   template:     metadata:       labels:         app: nfs-client-provisioner     spec:       serviceAccountName: nfs-client-provisioner       containers:         - name: nfs-client-provisioner           image: quay.io/external_storage/nfs-client-provisioner:latest           volumeMounts:           ...

Sample Kubernetes Cron Job code

cron jobs kubernetes ############ kube JOBS ######################### apiVersion: batch/v1 kind: Job metadata:   name: pi spec:   template:     spec:       containers:       - name: pi         image: perl         command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]       restartPolicy: Never   backoffLimit: 4 ########################################################### apiVersion: batch/v1 kind: Job metadata: name: consumer spec: completions: 5 template:   metadata:     name: consumer   spec:     containers:     - name: consumer       image: busybox       command: ["/bin/sh","-c"]       args: ["echo 'consuming a message'; sleep 5"]     restartPolicy: OnFailure...

Kubernetes Script to Deploy a postgres DB with Rollingupdate and persistent storage

apiVersion: apps/v1 kind: Deployment metadata:   name: postgres   namespace: default   labels:     app: postgres   annotations:     deployment.kubernetes.io/revision: "1" spec:   replicas: 1   strategy:     type: RollingUpdate     rollingUpdate:       maxUnavailable: 1       maxSurge: 1   selector:     matchLabels:       app: postgres   template:     metadata:       name: postgres       labels:         app: postgres     spec:       containers:         - name: postgres           image: "cpettech.docker.repositories.sap.ondemand.com/jtrack_postgres:howto"      ...

Push command for NetWorker Client Upgrade

########### Push command for NetWorker Client Upgrade ############### nsrpush Instructions        Upgrade NetWorker client using nsrpush. Use the following steps:   1. First Copy the NetWorker software to particular location on the NetWorker server.   2. Add the NetWorker software to repository using the command below:            Add software to repository on the Unix NetWorker Server         eg:- nsrpush   a  U  p NetWorker  v 8.0.2.2  m /tmp/NW Software       Add software to repository on the Windows NetWorker Server         eg:- nsrpush   a  W  p NetWorker  v 8.0.2.2  m C:\NetWorker Software     -a Add the Software to Repository     -U NetWorker server is installed on Unix     -W NetWorker serv...

ZFS script to take backup

# Ayotunde ITAYEMI (28-July-2009) and Modify for this backup by Lloyd Johnson # Please modify if deployed on another system or if the configuration # of this system changes @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ # Areas to modify (zfs list )file system : Note  during the installation make sure, that the directory #make /root must be check before installation, if that path is there, the script cannot execute, #however you can delete it or change the path from your script. AERAS marked with red must be #check before executing the script. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Restoring  ZFS file system # NOTE: I have commented out the backup for mmp01pool since that's # the temporary location in which rpool will be backed up to # the backup administrator MUST remember to take the backup # of the mmp01pool as the ZONE O/S resides in that pool # # alternatively, change the BACKUPLOCATION to a mounted external (NFS) filesyste m # then uncomment the commented steps for ...

How to stop kubernetes cluster created in AWS avoid incurring cost

How to stop kubernetes cluster created in  AWS avoid incurring cost Stop kubernetes cluster Get your instances group kops edit ig nodes edit nodes kops get ig edit your master and slave nodes kops edit ig <master-name> Change maxsize and minsize to 0 minsize: 0 maxSize: 0 Update your cluster kops update cluster --yes Rolling changes to stop the cluster kops rolling-update cluster --yes Rolling changes to start the cluster kops rolling-update cluster --cloudonly --force --yea

How To Restore Backup's from Networker CLI

[root@dha3323ddserver ~]# mminfo -avot -q volume= V720CTCLN.001 -r ssid,cloneid,ssretent, clretent,name,client,level, savetime|grep -i 2018|head -n 5 3274328914  1567448380 09/02/2021 09/02/2021 /rel01                    epicpprx03  full 12/31/2018 858411555   1567448380 09/02/2021 09/02/2021 /epic                     epicdrbackup incr 12/31/2018 2920181686  1572941192 11/05/2036 11/05/2036 backint:PHC               sap-phcdb1 manual 06/22/2019 2920184819  1572942248 11/05/2036 11/05/2036 MSSQL#SQLPRD16-AG:        dha-sql-prd16 txnlog 06/22/2019 2920185594  1572941192 11/05/2036 11/05/2036 MSSQL#SQLPRD16-AG:tmspe   dha-sql-prd16 incr 06/22/2019 [r...

How to Lunch an ECS Instance on a VPC

1) Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . 2) From the navigation bar, select the region where your reserved instance is located. 3) From the dashboard, click the Launch Instance button. 4) The Choose an Amazon Machine Image (AMI) page displays a list of basic configurations called Amazon Machine Images (AMIs). Choose the AMI that you want to use and click its Select button. 5) On the Choose an Instance Type page, select the hardware configuration and size of the instance to launch. Depending on the AMI you chose, you can stay within the free tier by selecting the Micro instances category, and selecting the t1.micro instance. When you are ready, click Next: Configure Instance Details. 6) On the Configure Instance Details page, select your VPC from the Network list, and subnet from the Subnet list. You can also configure other options as follows, and then click Next: Add Storage: 7) Public IP: Select this check box to request that your instance receives a pu...

Linux Bonds Management

ensla# modprobe -v bonding mode=0 arp_interval=100 arp_ip_target=192.168.1.254, 192.168.1.12 # tail -f /var/log/messages # ifconfig bond0 #### To Add a Bond without restarting the Network ##### ifenslave bond0 eth2 echo "+bond0" >  /sys/class/net/bonding_masters echo "+eth0" > /sys/class/net/bond0/bonding/slaves echo "+eth1" > /sys/class/net/bond0/bonding/slaves #### To remve a Bond ####### # ifenslave -d bond0 eth1 Or # echo -eth1 > /sys/class/net/bond0/bonding/slaves # ifconfig bond0 down # echo "-eth0" > /sys/class/net/bond0/bonding/slaves # echo "-eth1" > /sys/class/net/bond0/bonding/slaves # echo "-bond0" > /sys/class/net/bonding_masters # echo -bond0 > /sys/class/net/bonding_masters # rmmod bonding Configuring ifcfg-bond0 and ifcfg-bond1 interface on RHEL5 /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 ONBOOT=yes IPADDR=192.168.0.1 NETMASK=255.255.255.0 TYPE=Ethernet BONDING_OPTS="mo...

Deletes all ROOT VOLUME snapshots except retain most recent

#!/bin/bash ### Deletes all ROOT VOLUME snapshots except $RETAIN most recent. Script is designed to be run from inside ### instance on which it is operating. Depends on EC2 API Tools being pre-installed and configured.   ### How many snapshots do we want to retain? RETAIN=3   ### Obtain instance ID INSTANCE=`ec2-metadata -i |sed -n 's/^[a-z-]*: \(i-[0-9a-f]*\).*$/\1/p'`   ### Obtain region REGION=`ec2-metadata -z |sed -n 's/^[a-z]*: \([^0-9]*-[0-9]\).*$/\1/p'`   ### Obtain root volume ID VOLUME=`ec2-describe-instances ${INSTANCE} --region ${REGION} \         |sed -n 's/^.*\(vol-[0-9a-f]*\).*$/\1/p' |head -1`   ### Create a one-dimensional array consisting of date-sorted snapshots declare -a Snaps=(`ec2-describe-snapshots --region ${REGION} \         |grep -v "CreateImage" \         |grep -i ${VOLUME} \         |awk '{print $...

How to recover AWS ECS Instance ssh-keys

##Recovery Key ### ==create an instance with new pem key ==stop the actual instance ==detach the volume of actual instance ==attach the volume of actual instance to the new instance ==mount the volume (mount /dev/xvdf /mnt/recovery) ==copy new instance pem key to old instance volume ==umount the volume ==detach the old volume from the new instance ==attach the old volume to the old instance as (/dev/sda1) ==start the old instance ==login to the old instance with the recovery pem key ==How to know which Linux type you are running=== cat /etc/issue 3 fdisk -l 4 mkdir /mnt/recovery 5 mount /dev/xvdf /mnt/recovery/ 6 cat /home/ubuntu/.ssh/authorized_keys for Amazon, Redhat cat /home/ec2-user/.ssh/authorized_keys 7 cat /home/ubuntu/.ssh/authorized_keys > /mnt/recovery/home/ubuntu/.ssh/authorized_keys for Amazon, Redhat cat /home/ec2-user/.ssh/authorized_keys > /mnt/recovery/home/ec2-user/.ssh/authorized_keys 8 more /mnt/recovery/home/ubuntu/.ss...

Migrating Root VG ECS Instance

Just to make sure the below points doesnt throw any error, I have tried this on one of the Ubuntu Instances(12.04) to make sure the below steps work. It has worked as expected. 1) Create a complete image backup of the instance before proceeding. 2) Launch a test instance in the same AZ as that of the actual instance. (Lets call this instance "copy") 3) Stop the actual instance and detach the root volume(840 GB) and attach it to the "copy" instance as "/dev/sdf". 4) Create a new 50 GB volume and attach it to the "copy" instance as "/dev/sdg" 5) Format the volume of 50 GB with ext4 filesystem. sudo mkfs.ext4 /dev/xvdg(or /dev/sdg) 6) Once the 50GB volume has the filesystem, mount both the volumes.(Once you attach the volumes to the instances, it would show the volumes as /dev/xvdf and /dev/xvdg instead of /dev/sdf and /dev/sdg) mkdir orig mkdir second mount /dev/xvdf orig mount /dev/xvdg second 7) Copy the contents from the 840GB volume t...

Steps to shrink an AWS ECS EBS volume

Could you please try the following method to shrink your EBS volume: 1) Create a volume from your snapshot with the original volume size. 2) Create a new volume in the same Availability zone as the volume you just created above but use a size of 10GB. 3) Launch a new instance in the same availability zone as the volumes (do not add volumes etc to the instance). 4) Attach both volumes to the instance. Attach your large volume on /dev/sdf and the 10GB volume on /dev/sdg 5) SSH into the instance and make a file system on the new volume 'sudo mkfs.ext3 /dev/xvdg' 6) Mount both volumes: 'sudo mkdir /mnt/old | sudo mount /dev/xvdf /mnt/old' and 'sudo mkdir /mnt/new | sudo mount /dev/xvdg /mnt/new' 7) Use rsync to copy the volumes: 'rsync -aHAXxSP /mnt/old /mnt/new' 8) Unmount the volumes 'sudo umount /dev/xvdf | sudo umount /dev/xvdg' 9) Stop the instance 10) Detach all the volumes from the instance including the root volume. 11) Attach the 10GB volum...

How to Convert S3 Backed Windows AMIs to EBS Backed Windows AMIs

  How to Convert S3 Backed Windows AMIs to EBS Backed Windows AMIs   Note: The preferred term for "S3-backed" is now "instance store-backed." Introduction: If you have Windows 2003 AMIs in the AWS environment, they are likely S3-backed, which of course means that they can’t be stopped and then restarted. (Windows 2008 is only available as EBS-backed AMIs, so these instructions don’t apply to them.) Steps:     Launch an instance of the S3-backed Windows AMI that you want to migrate     Log into the instance and download dd.exe.  This is *nix tool that does block copying of raw devices.         We tested with version dd-0.5 from this site: http://www.chrysocome.net/dd , although the newer version appers to work too.     Create a 10GB EBS volume in the same AZ as the running instance and attach it to the running instance.         You don't need to mount it or fo...

Procedure to create X2go windows client on Linux server

  I replicated the same on a RHEL 6.4 AMI and did the following procedures: Configuring the RHEL Instance ****************************** First, update the instance from the RHEL repository # yum -y update If this is the first time that you run this command, it could take a long time on a new instance as it updates all libraries and dependencies on the instance. Next we will start to install the X-Window system and related packages # yum -y groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts" Now we install the KDE desktop # yum -y groupinstall kde-desktop We also want to install some optional packages from the repository, so we need to make a small change to yum.conf to allow this. Using your favorite editor, edit the file /etc/yum.conf and add the following line to the [main] section of the file: group_package_types=default mandatory optional Once you have done this, you will be able to install the following package on the EC2 ins...

Script to create storage on AWS

Install latest fuse release Start first by removing existing fuse packages installed on your system. yum remove fuse fuse* fuse-devel Install development tools and required packages if you don't already have them. yum install gcc libstdc++-devel gcc-c++ curl curl* curl-devel libxml2 libxml2* libxml2-devel openssl-devel mailcap Download, compile and install fuse. Use this link to get the latest fuse release. mkdir -p /tmp/compile && cd /tmp/compile wget http://downloads.sourceforge.net/project/fuse/fuse-2.X/2.8.6/fuse-2.8.6.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Ffuse%2Ffiles%2Ffuse-2.X%2F&ts=1324112754&use_mirror=freefr tar -zxf fuse-2.8.6.tar.gz cd fuse-2.8.6 ./configure --prefix=/usr make make install Update ldconfig export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/ ldconfig Load fuse module and confirm we use our compiled version modprobe fuse pkg-config --modversion fuse (should return 2.8.6) Cleanup a bit... cd /tmp/compile rm -rf fuse*...

How to install Java on Linux

 This is how I install java on Linux if you don't want to install it using yum. download java from http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase14-419411.html jre-1_5_0_12-linux-amd64.bin chmod +x jre-1_5_0_12-linux-amd64.bin ./jre-1_5_0_12-linux-amd64.bin [root@duim001zatcrh ~]# alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.5.0_12/bin/java 1 [root@duim001zatcrh ~]# alternatives --install /usr/bin/java java /usr/java/jre1.5.0_12/bin/java 2 [root@duim001zatcrh ~]# alternatives --config java There are 3 programs which provide 'java'.   Selection    Command ----------------------------------------------- *+ 1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java    2           /usr/lib/jvm/jre1.5.0_12/bin/java    3           /usr/java/jre1.5.0_1...

Scripts to send notification when an instance fails

eps: Please note this script will most likely send you notification to your spam message. This script should send emails to you when an ECS instance fails 1) apt-get install bsd-mailx -y (that will install mailx) 2) vi /etc/init.d/emailstartstop 3) paste the content of the script into the above file. 4) chmod 755 /etc/init.d/emailstartstop 5) chkconfig --level 34561 emailstartstop on 7) service emailstartstop start && service emailstartstop stop to test. The script is as follows: #!/bin/bash # # emailstartstop Send an email on server startup and shutdown. # # chkconfig: 2345 99 01 # description: Send an email on server startup and shutdown. EMAIL="youremail@gmail.com" STARTSUBJ=`hostname`" started on "`date` STARTBODY="Just letting you know that server "`hostname`" has started on "`date` STOPSUBJ=`hostname`" shutdown on "`date` STOPBODY="Just letting you know that server "`hostname`" has shutdown on "`date...

FACTORS AFFECTING THE USERS’ SENSE OF SECURITY AND TRUST IN INTEGRATING ELECTRONIC HEALTH RECORD TO CLOUD

Image
Factors Affecting the Users’ Sense of Security and Trust in Integrating Electronic Health Record TO CLOUD   By   Lloyd Enyrebe Johnson   Presented to   Prof. Steve Page, S-Master of Science, Information System Management ( S-MScISM ) University of Salford, Manchester United Kingdom   30th of June 2017   PREFACE I am grateful to God who has made this journey a success. To everyone who have assisted me thus far, I say a big thank you. I wish to acknowledge and sincerely thank my dissertation Supervisor. Prof. Dr. Steve Page For his guidance, patience and constant encouragement. During   my   thesis,   he   was   instrumental   in   inspiring   me   to   work   towards   solving   a well-defined   problem   that   would   result   in   a   publishable   article and paper.   It would not have been possible for me to comple...