Skip to content

Instantly share code, notes, and snippets.

@yuvipanda
yuvipanda / Dockerfile
Created January 7, 2020 23:30
Simple automatic HTTPS with certbot on kubernetes
FROM python:3.7-buster
RUN pip install --no-cache certbot kubernetes
COPY autocert.py /usr/local/bin/autocert.py
description: "Build an image via hubploy"
parameters:
deployment:
type: string
push:
type: boolean
default: false
docker:
- image: python:3.7-slim-buster
@yuvipanda
yuvipanda / dask.py
Last active November 21, 2019 19:11
import os
import boto3
import yaml
jupyter_image = os.environ['JUPYTER_IMAGE']
session = boto3.Session()
credentials = session.get_credentials()
aws_creds = {'key': credentials.access_key, 'secret': credentials.secret_key}
dask_worker_spec = f'''kind: Pod
from oauthenticator.generic import GenericOAuthenticator
class CustomAuthenticator(GenericOAuthenticator):
async def authenticate(self, handler, data=None):
resp = await super().authenticate(handler, data)
# resp is a dict mentioned here: https://github.com/jupyterhub/oauthenticator/blob/master/oauthenticator/generic.py#L163
# modify it as you wish, set username key
modified_resp = resp.copy()
modified_resp['username'] = resp['auth_state']['oauth_resp']['attrib']['email']
return modified_resp
@yuvipanda
yuvipanda / values.yaml
Created October 2, 2019 18:05
Secureish hub
jupyterhub:
prePuller:
continuous:
enabled: false
scheduling:
userScheduler:
enabled: false
hub:
networkPolicy:
enabled: true
@yuvipanda
yuvipanda / start-vm.py
Created September 24, 2019 23:43
Start a VM with Pangeo image & let you access it
#!/usr/bin/env python
import re
import subprocess
import time
import argparse
import json
IMAGE = 'pangeo/base-notebook:2019.09.21'
ZONE = 'us-central1-b'
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
FROM yuvipanda/pangeo-base-notebook-onbuild:2019.04.15-4
@yuvipanda
yuvipanda / gist:1b58c4ed47148c5e9c53ea492161fec1
Created January 9, 2019 20:10
account-management on core node
Nov 22 11:16:25 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Starting Google Accounts daemon.
Nov 22 11:16:25 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Creating a new user account for yuvipanda.
Nov 22 11:16:25 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Created user account yuvipanda.
Nov 22 11:16:25 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Creating a new user account for choldgraf.
Nov 22 11:16:25 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Created user account choldgraf.
Nov 22 11:16:25 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Creating a new user account for minrk.
Nov 22 11:16:25 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Created user account minrk.
Nov 22 11:16:25 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Creating a new user account for gke-df315ed616f010764e03.
Nov 22 11:16:26 gke-prod-a-core-e77a049e-591f google-accounts[475]: INFO Created user account gke-df315ed616f010764e03.
Nov 22 11:16
@yuvipanda
yuvipanda / ldapsearchauth.py
Created January 7, 2019 08:08
A JupyterHub authenticator that outsources to ldapsearch
"""
An authenticator that outsorces auth to ldapsearch!
Because LDAP is hard and old and terrible and you should not use it.
"""
import os
from jupyterhub.auth import Authenticator
import pexpect.exceptions
import pexpect.popen_spawn
from traitlets import Unicode