Giter VIP home page Giter VIP logo

deployment's Introduction

⚠️ This Repository is archived. Please take a look at the supported self-hosted deployment options at posthog.com/docs/self-host ⚠️

PostHog deployment options

If you want a quick install on an Ubuntu VM

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/deployment/HEAD/compose/deploy.sh)"

You can find a full list of guides at https://posthog.com/docs/deployment

Deployments configured in this repo:

Docker Compose

Via Docker Compose Check out /compose directory

Kubernetes

https://posthog.com/docs/deployment/deploy-kubernetes

Via Helm Chart

Terraform on Digital Ocean

https://posthog.com/docs/deployment/deploy-digital-ocean

  • DigitalOcean - Single node install
  • DigitalOcean - Distributed with Redis, Posgres, Load Balancer, LetsEncrypt, SSL/TLS only

Contributing

If you have a favorite config that you use we would to love include it here! We are always looking for fresh pull requests.

Questions?

deployment's People

Contributors

amites avatar fuziontech avatar guidoiaquinti avatar imhmdb avatar lharress avatar macobo avatar mariusandra avatar paolodamico avatar sj26 avatar timgl avatar twixes avatar ungless avatar yakkomajuri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

deployment's Issues

Updating cloudformation stack failed

I tried updating a previously deployed cloudformation stack via their update button to bump database instance and worker sizes.

This failed during updating TaskDefinition step with the following error:

Invalid request provided: Create TaskDefinition: No Fargate configuration exists for given values. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: XXX; Proxy: null)

Will investigate at a later date.

Discussion: Docker Image to use

We are using posthog:latest on a few images here, which, while making things easier for us (we don't have to be updating version numbers), means a user might get an unstable deployment (since our latest tag is a build from the HEAD in master).

Wondering if this is something we should talk about @macobo

Allow Cloudformation Parameters for ALB to use re-direct

Hello,

I would like an enhancement to the Cloudformation template to allow ALB to provide a re-direct value for port 80, see below:

PublicLoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- TargetGroupArn: !Ref 'DummyTargetGroupPublic'
Type: 'forward'
LoadBalancerArn: !Ref 'PublicLoadBalancer'
Port: 80
Protocol: HTTP

Link: https://github.com/PostHog/deployment/blob/master/aws/cloudformation/ecs/posthog.yaml

Linting errors in cloudformation template

After #21 lands, there are several linting errors in posthog.yaml:

⟩ cfn-lint aws/cloudformation/ecs/posthog.yaml                                                                                                                                                             14:31:14
W2001 Parameter SentryDSN not used.
aws/cloudformation/ecs/posthog.yaml:146:3

E3012 Property Resources/EcsSecurityGroupIngressFromPublicALB/Properties/IpProtocol should be of type String
aws/cloudformation/ecs/posthog.yaml:359:7

E3012 Property Resources/EcsSecurityGroupIngressFromPrivateALB/Properties/IpProtocol should be of type String
aws/cloudformation/ecs/posthog.yaml:366:7

E3012 Property Resources/EcsSecurityGroupIngressFromSelf/Properties/IpProtocol should be of type String
aws/cloudformation/ecs/posthog.yaml:373:7

E3012 Property Resources/PublicLoadBalancerSG/Properties/SecurityGroupIngress/0/IpProtocol should be of type String
aws/cloudformation/ecs/posthog.yaml:397:13

W3005 Obsolete DependsOn on resource (PublicLoadBalancer), dependency already enforced by a "Ref" at Resources/PublicLoadBalancerListener/Properties/LoadBalancerArn/Ref
aws/cloudformation/ecs/posthog.yaml:430:9

E3012 Property Resources/PrivateLoadBalancerIngressFromECS/Properties/IpProtocol should be of type String
aws/cloudformation/ecs/posthog.yaml:452:7

W3005 Obsolete DependsOn on resource (PrivateLoadBalancer), dependency already enforced by a "Ref" at Resources/PrivateLoadBalancerListener/Properties/LoadBalancerArn/Ref
aws/cloudformation/ecs/posthog.yaml:485:9

W3011 Both UpdateReplacePolicy and DeletionPolicy are needed to protect Resources/PosthogDB from deletion
aws/cloudformation/ecs/posthog.yaml:696:3

W2501 Password shouldn't be hardcoded for Resources/PosthogDB/Properties/MasterUserPassword
aws/cloudformation/ecs/posthog.yaml:707:7

@fuziontech Which of these should we action? The Sentry, Password and Policy warnings seem especially juicy.

Own thoughts:

  1. Add SentryDSN to be used as an environment variable (as intended)
  2. Make DB user/password part of the variables, use current values as defaults
  3. Add UpdateReplacePolicy and DeletionPolicy are needed to protect Resources/PosthogDB from deletion

After this we could also automate this linting via github actions.

SITE_URL not configured on CF template

The SITE_URL environment variable is necessary for emails and some toolbar features to work correctly. When launching an instance with the CloudFormation template, we don't guide the user through setting up this environment variable.

Confusing alarms when launching AWS CF template

Recently I launched a CF template to set up the infrastructure for a customer. Just after the resources were deployed, I received a few alarms in the SNS topic. The alarms were cleared pretty soon, presumably just due to a transition state on the launch of the resources. While this is not critical, as the alarms were cleared soon, it's not a great experience that the first emails you get after the deployment are error notices.

Alarms triggered:

  • Posthog-ElastiCacheMemoryFullAlarm. Threshold Crossed: 1 datapoint [4.65436672E8] was less than the threshold (6.4E8). Redis memory over the last 10 minutes is too low, your instance might not be ingesting events
  • Posthog-RDSDiskFullAlarm. Threshold Crossed: 1 datapoint [1.015771136E10] was not less than the threshold (1.0E9)

Suggestion: use a non-default CIDR block for AWS VPC

The Cloudformation template currently creates a VPC with a hard-coded CIDR of10.0.0.0/16 which is the default CIDR block used by most AWS VPCs.

Unfortunately, this means that you can't create a peering connection between the Posthog VPC and another VPC that was created using these defaults, so inter-VPC communication requires the more expensive Transit gateway.

I don't think there's a way to change this for an existing deployment, but it would prevent a few headaches for future deployments if Posthog selected a less common CIDR block for it's VPC.

Use secrets storage in CF template

When deploying with the CF template we generate a SECRET_KEY and also store it under password in AWS Secrets Manager. However, in the task definition we set a plain text version as an environment variable instead of making use of the secret version.

Logs are not reaching cloudwatch

Currently logs from ECS from our cloudformation setup are not reaching cloudwatch - it only seems to contain logs only for server boot.

Make 500 page a bit nicer while webpack builds

It's a little worrying to see 500's when you start the cloud formation stack and the first thing you see is a 500. If you didn't know any better you might kill the stack before waiting for webpack to finish. Would be nice to have a 'tidying things up' or 'cleanup up the dust' landing page while webpack finishes.

ECS posthog.yml parameter references

Among the parameters specified in deployment/aws/cloudformation/ecs/posthog.yml are EmailUserSSL and EmailUserTLS. In the container definition I see Ref! 'EmailUseTLS' and Ref! 'EmailUseSSL'.

When deploying the script I get ValueError: Ref! 'EmailUseSSL' is an invalid value for EMAIL_USE_SSL, expected boolean and such.

I assume these are typos?

DB Environment variables do not use CloudFormation template parameters

The DATABASE_URL environment variable for the ECS Task definition uses hard coded values for username and password, as a result changing the RDS username or password results in a 503.

- Name: DATABASE_URL
Value: !Join ['', ['postgres://posthog:posthogadmin@', !GetAtt [PosthogDB, Endpoint.Address], ':', !GetAtt [PosthogDB, Endpoint.Port], '/posthog']]

- Name: DATABASE_URL
Value: !Join ['', ['postgres://posthog:posthogadmin@', !GetAtt [PosthogDB, Endpoint.Address], ':', !GetAtt [PosthogDB, Endpoint.Port], '/posthog']]

- Name: DATABASE_URL
  Value: !Join ['', ['postgres://', !Ref 'RDSMasterUser', ':', !Ref 'RDSMasterUserPassword', '@', !GetAtt [PosthogDB, Endpoint.Address], ':', !GetAtt [PosthogDB, Endpoint.Port], '/posthog']]

Should do the trick for both.

Database protection on CF stack

Related to PostHog/posthog.com#1167 & this user report we definitely need to add some protections against accidental data deletion. Some suggestions:

  • Add database protection by default to the RDS instance.
  • Set a default PITR rolling backup for something low like 2-4 days. This will ensure there's something to rollback on just in case something happens and it won't add too much infrastructure expense.
  • We need a way to update the CF stack without recreating the DB. If this is definitely not possible for now, can we add a warning for when you're trying to recreate your stack?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.