/images/avatar580.png

Salvatore Nasca

Website about Tech, Cool Stuff and Life Hacks

Masa Architecture

/posts/images/masa_architecture.jpg

What is it?

MASA stands for Mesh App and Service Architecture. It is a new architectural model that was introduced by Gartner in 2016. MASA is designed to address the challenges of modern application development, such as the need for agility, flexibility, and scalability.

In a MASA architecture, applications are made up of a mesh of independent and autonomous services. These services are connected to each other through APIs. This allows applications to be easily composed and decomposed, making them more agile and flexible.

Kubernetes Deploy Aws Spot Fleet

This is an example of a Kubernetes manifest that you can use to deploy a spot fleet with high availability in AWS.

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: LoadBalancer
  selector:
    app: my-app
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  replicas: 8
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - my-app
              topologyKey: "kubernetes.io/hostname"
      containers:
      - name: my-app
        image: my-app:latest
        ports:
        - containerPort: 80
---
apiVersion: spotinst.com/v1
kind: Fleet
metadata:
  name: my-spot-fleet
spec:
  type: kubernetes
  minimum: 1
  maximum: 8
  resource:
    instanceTypes:
      - type: c5.large
      - type: m5.large
      - type: r5.large
    launchSpecifications:
      iamInstanceProfile: arn:aws:iam::1234567890:instance-profile/my-instance-profile
      securityGroupIds:
        - sg-12345678
      subnetIds:
        - subnet-12345678
  availability:
    availabilityZones:
      - us-west-2a
      - us-west-2b
      - us-west-2c
  policies:
    gracefulTermination:
      enabled: true
      expirationPeriod: 60
    healthCheck:
      enabled: true
      gracePeriod: 60
      interval: 30
    scaleDown:
      evaluationPeriods: 1
      maxScaleDownPercentage: 50
      policies:
        - policyName: scale-down-policy
          type: cloudWatchAlarm
          threshold: 30
          period: 300
          evaluationPeriods: 3
          operator: less-than-or-equal
          statistic: average
          dimensions:
            - name: AutoScalingGroupName
              value: "{{.AutoscalingGroupName}}"
          namespaces:
            - AWS/EC2
          metricName: CPUUtilization
          unit: Percent
  integration:
    enabled: true
    clusterName: my-cluster
    namespace: default


 

This manifest will create a Kubernetes service that exposes a load balancer, a deployment with 8 replicas of the my-app application, and a spot fleet with a minimum of 1 and a maximum of 8 instances. The spot fleet will use c5.large, m5.large, and r5.large instance types and will be launched in the us-west-2a, us-west-2b, and us-west-2

Ansible Playbook Example - Linux Server deployment with SSH Public Key

This is an example of an Ansible Playbook to deploy a Linux Server with a Public Key for SSH.

---

- hosts: all
  become: true
  tasks:
  
  - name: Install and update system packages
    apt:
      name: "{{ packages }}"
      state: latest
    vars:
      packages:
        - python
        - python-apt
  
  - name: Install and configure SSH
    apt:
      name: openssh-server
    become: true
    become_user: root
    vars:
      packages:
        - openssh-server

  - name: Start and enable SSH service
    service:
      name: ssh
      state: started
      enabled: true

  - name: Add public SSH key
    authorized_key:
      user: "{{ ansible_user }}"
      key: "{{ ssh_public_key }}"
    vars:
      ssh_public_key: "ssh-rsa AAAAB...Z user@example.com"

 

What Is Aws

What is Amazon Web Services? (aka AWS)

Amazon Web Services (AWS) is a cloud computing platform that provides a wide range of services for building, deploying, and managing applications. With AWS, businesses can take advantage of on-demand, scalable, and flexible computing resources to meet their specific needs.

AWS offers a variety of services, including storage, databases, analytics, machine learning, security, and more. Some of the most popular AWS services include Amazon S3, Amazon EC2, Amazon RDS, Amazon Redshift, and Amazon EMR.