2019/02/28

AWS ALB redirect HTTP to HTTPS configuration in command line

CURRENT CONFIGURATION: AWS Application Load Balancer created by Elastic Beanstalk
OBJECTIVE: redirect HTTP to HTTPS on port 80 by default by command line
ISSUE: lack of clear example.
SOLUTION:
aws elbv2 modify-listener --listener-arn <$ebs_alb_listener_http> --default-actions '[{"Type": "redirect", "RedirectConfig": {"Protocol": "HTTPS", "Port": "443", "Host": "#{host}", "Query": "#{query}", "Path": "/#{path}", "StatusCode": "HTTP_301"}}]' --region <$my_aws_region>

LINKS: Elastic Load Balancing Announces Support for Redirects and Fixed Responses for Application Load Balancer
AWS cli elbv2 modify-listener

2018/10/25

Setup EKS Kubernetes with 2 Autoscaling groups in private and public subnets

CURRENT CONFIGURATION: AWS, EKS Kubernetes 1.10.3.
OBJECTIVE: Setup EKS Kubernetes with 2 Autoscaling groups in private and public subnets. One nodes group stack should have 3-10 nodes in private subnets. Second nodes group stack should have 2-4 nodes in public subnets.
ISSUE: AWS IAM Authenticator configuration map unregister from EKS cluster different nodes group.
SOLUTION:
Create AWS IAM Authenticator configuration map with both nodes groups:
  cat > ./aws-auth-cm-all.yaml <
apiVersion: v1
kind: ConfigMap
metadata:
  name: aws-auth
  namespace: kube-system
data:
  mapRoles: |
    - rolearn: ${EKS_INSTANCE_ROLE_PUBLIC}
      username: system:node:{{EC2PrivateDNSName}}
      groups:
        - system:bootstrappers
        - system:nodes
    - rolearn: ${EKS_INSTANCE_ROLE_PRIVATE}
      username: system:node:{{EC2PrivateDNSName}}
      groups:
        - system:bootstrappers
        - system:nodes
EOF
  cat ./aws-auth-cm-all.yaml
  kubectl apply -f ./aws-auth-cm-all.yaml
LINKS:
https://docs.aws.amazon.com/eks/latest/userguide/launch-workers.html
P.S. I have to change Blog to different, code friendly.

2018/07/30

Jenkins pipeline example short

ОКРУЖЕНИЕ: Jenkins 2.121.2 on Ubuntu 16.04.4 LTS
ЦЕЛЬ: Сконфигурировать Jenkins pipeline.
РЕШЕНИЕ:
Jenkinsfile-pipeline-example-short.groovy
// Jenkins pipeline example short. Jenkins 2.121.2 on Ubuntu 16.04.4 LTS
// Jenkinsfile-pipeline-example-short.groovy
pipeline {
   agent any

   environment {
      MY_DOCKER_DIR = 'docker-images'
      MY_DOCKER_EXPORT_DIR = '/tmp'
      MY_DOCKER_IMPORT_DIR = '/mnt/data/jenkins/jenkins-agent'
      MY_DEST_SERVER = 'server-01'
   }

   stages {

      stage('Clone repository on master') {
         agent { label 'master' }
         steps {
            echo 'Clone repository on master'
            REPLACE_ME
         }
      }

      stage('Stop QA env') {
         agent { label 'master' }
         steps {
            timeout(50) {
               echo 'Shutdown docker containers'
               REPLACE_ME
            }
         }
      }

      stage('Clone repository on agent') {
         agent { label 'MY_qa_deploy' }
         steps {
            echo 'Clone repository on agent'
            REPLACE_ME
         }
      }

      stage('Run docker images and test') {
         agent { label 'master' }
         steps {
            echo 'Run docker images and test'
            timeout(30) {
            REPLACE_ME
            }
            script {
               REPLACE_ME
            }
         }
      }

      stage('Build docker images') {
         agent { label 'master' }
         steps {
            echo 'Build docker images'
            REPLACE_ME
         }
      }

      stage('Export docker images') {
         agent { label 'master' }
         steps {
            timeout(20) {
            echo 'Export docker images'
            REPLACE_ME
            }
         }
      }

      stage('Copy to destination server') {
         agent { label 'master' }
         steps {
            sh 'echo "Copy to destination server env.MY_DEST_SERVER: \${MY_DEST_SERVER}"'
            REPLACE_ME
         }
      }

      stage('Import on destination server') {
         agent { label 'MY_qa_deploy' }
         steps {
            timeout(20) {
               sh 'echo "env.MY_DOCKER_IMPORT_DIR: \${MY_DOCKER_IMPORT_DIR}; env.MY_DOCKER_DIR: \${MY_DOCKER_DIR};"'
               REPLACE_ME
            }
         }
      }

      stage('Start on destination server') {
         agent { label 'MY_qa_deploy' }
         steps {
            timeout(25) {
               echo 'Start on destination server'
               REPLACE_ME
            }
         }
      }
      
      stage('Test QA from build') {
         steps {
            script {
               REPLACE_ME
            }
         }
      }
   }

   post {
      always {
         echo 'INFO: Post: always'
         script {
            mail to: 'my-build-notification-always@example.com', subject: 'jenkins bot', body: 'test always', mimeType: "text/html"
         }
      }
      success {
         echo 'INFO: Post: success'
         script {
            mail to: 'my-build-notification-success@example.com', subject: 'Build success', body: 'Build success', mimeType: "text/html"
         }
      }
      failure {
         echo 'INFO: Post: failure, failed'
         script {
            mail to: 'my-build-notification-failure@example.com', subject: 'Build failed', body: 'Build failed', mimeType: "text/html"
         }
      }
   }
}

2015/10/30

Unifi Access Point freezes as provisioning in Unifi on Ubuntu 14.04

ОКРУЖЕНИЕ: UniFi AP-AC v2, Unifi 4.7.5, Ubuntu 14.04.3 LTS на Amazon AWS t2.micro, Site-to-Site VPN соединение.
ЦЕЛЬ: Конифигурация Ubiquiti Wi-Fi Access Point UniFi AP-AC в офисе через Uniti в облаке.
ПРОБЛЕМА: 
Ubiquiti Wi-Fi Access Point зависает в статусе provisioning (provisioning looping) .
РЕШЕНИЕ:
Обновить Java.
apt-get purge -y openjdk-6-*
apt-get install -y openjdk-7-jdk
update-alternatives --config java
reboot

2015/10/14

perl: warning: Please check that your locale settings

ОКРУЖЕНИЕ: Ubuntu 14.04.3 LTS
ЦЕЛЬ: Запускать команды без неисправленных предупреждений.
ПРОБЛЕМА: 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_PAPER = "en_IE.UTF-8",
        LC_ADDRESS = "en_IE.UTF-8",
        LC_MONETARY = "en_IE.UTF-8",
        LC_NUMERIC = "en_IE.UTF-8",
        LC_TELEPHONE = "en_IE.UTF-8",
        LC_IDENTIFICATION = "en_IE.UTF-8",
        LC_MEASUREMENT = "en_IE.UTF-8",
        LC_TIME = "en_IE.UTF-8",
        LC_NAME = "en_IE.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
РЕШЕНИЕ:
apt-get install language-pack-en

Запустить команду.