Monday 16 April 2018

end is nigh: serverless

"For a small company focused on rapid growth, the last thing we wanted to deal with was disk space and memory management, logging agents, security patches, operating system updates, and other traditional server management processes."

Thursday 12 April 2018

recursive

def recursive_countdown(x):
    print('Countdown: ' + str(x))
    if x == 1:
        return 1
    else:
        return recursive_countdown(x - 1)

recursive_countdown(5)


def recursive_fib(x):
    #print('Fib: ' + str(x))
    if x in [0, 1]:
        return x
    else:
        return (recursive_fib(x - 1) + recursive_fib(x -2 ))

# this algo can be easily improved if answers are indexed

print(recursive_fib(5))
print(recursive_fib(6))
print(recursive_fib(7))
print(recursive_fib(8))

Wednesday 11 April 2018

Python: sort by value then key

No idea yet how this works, or why.

>>> d = {'apple': 7, 'banana': 3, 'almond': 7, 'peach': 4, 'beetroot': 3}
>>> sorted(d.iteritems(), key=lambda(k, v): (-v, k))
[('almond', 7), ('apple', 7), ('peach', 4), ('banana', 3), ('beetroot', 3)]

Thursday 5 April 2018

Basic Ansible in 10 mins


  • "site.yml" file
    • playbook containing
      • "roles" that will be applied to individual host groups / "hosts"
      • how the hosts will be accessed
        • and by what user to run as
      • Puppet equivalent is "nodes.pp"
  • "hosts" file
    • use real/local DNS hostname to define which hosts are in which hostgroups
      • example: webserver1, webserver2, haproxy1, haproxy2, mongo1, mongo2
      • some variables like "port" can be added too
  • "group-vars" directory
    • key/value pairs to use when generating output from template files
    • files named identically to hostgroup names defined in "hosts" file
    • these are more in-line in Puppet, and less controllable/flexible
  • "roles" directory
    • Puppet equivalents are "modules"/"classes"
    • directories arbitrarily named to match "roles" in site.yml
    • e.g. "tomcat", "common", "mongod"
    • "templates" directory
      • files with variables that are resolved using "group-vars" key/values
      • moved on to target systems using task keyword "template"
      • same name is used in Puppet
    • "files"
      • raw files to be moved into place on the target filesystems
      • used by tasks with keyword "file"
      • same name used in Puppet
    • "handlers"
      • "main.yml"
      • control system services on target systems
        • "service" keyword
        • "state", e.g. "restarted"
        • in Puppet, these are not broken out from other "resources"
    • "tasks"
      • this is the core list of actions to perform on target systems
      • Puppet equivalents are "includes"/"classes", maybe "modules" as well
      • "main.yml"
        • collection of tasks
        • uses yml structure
          • "name" is arbitrary reference for developers
          • ansible keyword to perform some action on the system
            • ansible keywords: "file", "template", "command"
              • puppet equivalents are called "resources"
          • conditionals/dependencies: "when", "notify", "wait_for"


Keeping up with Hashicorp's Vault

To retrieve secrets, employees replace plaintext secrets with a call to Secrets Manager APIs, eliminating the need to hard-code secrets in source code or update configuration files and redeploy code when secrets are rotated.




Interview questions: 2020-12

Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer  Networking Layer 1 vs Layer 4 haproxy u...