Services - hqzhang/cloudtestbed GitHub Wiki

DevOps automation

DevOps automation can be achieved by repackaging platforms, systems, and applications into 
reusable building blocks through the use of technologies such as virtual machines and 
containerization.

Implementation of DevOps automation in the IT-organization is heavily dependent on tools, 
[unreliable source?]which are required to cover different 
areas of the systems development lifecycle (SDLC):

1)Infrastructure as code — Ansible, Terraform, Puppet, Chef

2)CI/CD — Jenkins, TeamCity, Shippable, Bamboo, Azure DevOps

3)Test automation — Selenium, Cucumber, Apache JMeter

4)Containerization — Docker, Rocket, Unik

5)Orchestration — Kubernetes, Swarm, Mesos

6) Software deployment — Elastic Beanstalk, Octopus, Vamp

7) Measurement — Datadog, DynaTrace, Kibana, NewRelic, ServiceNow
8) ChatOps — Hubot, Lita, Cog

Install Kube AKS

#create vm
az group create --name myResourceGroup --location eastus
az vm create \
    --resource-group myResourceGroup \
    --name myVM \
    --image win2016datacenter \
    --admin-username azureuser \
    --admin-password myPassword
#create aks
az provider register -n Microsoft.ContainerService
Az group create --name myaks --location east's

Az aks create --resource-group my-aks --name kubelive --node-count 1 --generate-ssh-keys
Az aks install-cli
Az aks get-credentials --resource-group my-aks --name kubelive

Kc get cs
Kc cluster-info

Kc create -f azure_vote.yaml
Kc get pod --watch
Kc get svc --watch

Kc run --image=nginx mewed
Kc get pods
Kc expose pod mewed-xxxxx --port=80 --type=LoadBalancer


Install Kube EKS

00) create eks cluster
1) create iam role for eke
   EKSclusterpolicy
   EKSservicepolicy

2) create vpc and security group by heat (cloud formation) 
   https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-02-11/amazon-eks-vpc-sample.yaml
      i)SecurityGroups	sg-0cdbe8bff2aaf5ef2	 
      ii)SubnetIds	     	
      subnet-0aeb1d53ce3ea04b0,subnet-053d6b9a16c5025b7,subnet-0361a2922852eba79	
      iii) VpcId vpc-01d8c73d2029f1b77

3) create eks cluster
 
4) install kubectl and aws-iam-authenticator

5) config kubeconfig
    aws eks --region us-west-2 update-kubeconfig --name nginxcluster --role-arn "arn:aws:iam::186454388355:role/eksrole"    

11) deploy worker nodes
  https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-02-11/amazon-eks-nodegroup.yaml

22) let workers join cluster
curl -o aws-auth-cm.yaml https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-02-11/aws-auth-cm.yaml

AWS vs OS

1)dashboard     Console vs Horizon
2)orchestration Cloudformation vs Head
3)database      RDS    vs  Trove
4) Object storage
Store files: media, documents, images etc
               Swift   vs   S3 - Simple Storage Service
5) Block storage
Create virtual disk drives (volumes). 
               Cinder    vs  EBS - Elastic Block Storage
5) Identity    Keystone  vs  IAM 
6) Security    keypair/securitygroup vs keypair/security``
7) monitoring  Ceilometer  vs Cloudwatch
8) networking  Neutron .   vs VPC
9) Compute .   Glance   vs AMI

Use a daemon/service can garentee an app always running, there are two kind of service used in ubuntu system are described as following:

  1. Upstart Service
  1. Systemd Service
1. Create a script or executable file test_service
DATE=`date '+%Y-%m-%d %H:%M:%S'`
echo "Example service started at ${DATE}" | systemd-cat -p info
while :
do
echo "Looping...";
sleep 30;
done
2. Copy the script to /usr/bin with executable: 
3. Create a Unit file as a systemd service: 
    vim /lib/systemd/system/myservice.service
[Unit]
Description=Example systemd service.
[Service]
Type=simple
ExecStart=/bin/bash /usr/bin/test_service.sh
[Install]
WantedBy=multi-user.target

4. Copy the unit file to /etc/systemd/system with permissions:
   /etc/systemd/system/myservice.service with 644
5. start service
    systemctl myservice start