Place beans in a large bowl and cover with cold water by 2 inches. Refrigerate 8 to 12 hours, then drain. Combine beans and 8 cups water in a large saucepan. Add onion, bay leaf, and prosciutto ends, if using. Bring to a boil, then reduce heat and simmer until beans are just tender (but not mushy, as they should hold their shape in the soup), 30 to 45 minutes. Drain, reserving beans and 4 cups liquid; strain reserved liquid. Discard onion, bay leaf, and prosciutto, and cover beans.
Heat the oil in a large stockpot over medium-low heat until shimmering. Add celery, carrot, and onions, and cook, stirring often to prevent them from scorching on the bottom, until deep golden brown, about 30 minutes.
Add leek and garlic to soffrito and cook, stirring often, until soft, about 4 minutes. Raise heat to medium-high, and then add sliced celery and carrots along with the potato, zucchini, and green beans. Cook, stirring often, until vegetables are golden, about 5 minutes.
Stir in reserved bean liquid, the tomatoes and juice, kale, cabbage, stock, cheese rind, prosciutto ends (if using), bay leaf, and red pepper flakes; season with salt and black pepper. Bring to a boil, then reduce heat to a simmer. Cover and cook 1 hour.
Stir in beans and continue cooking until all vegetables are very tender, 20 to 30 minutes more.
For basil pesto, cover garlic in a small saucepan with water by 1 inch. Bring to a boil over high heat, then immediately drain and let garlic cool to room temperature.
With a large mortar and pestle, pound together basil, garlic, pine nuts, and salt until the basil is pulverized and the pine nuts and garlic are pasty, about 10 minutes. Add the cheese and pound to incorporate. Mixing vigorously, pour in the oil in a slow steady stream, and mix until combined (it will not be emulsified). Serve immediately or cover with a layer of oil and store in an airtight container in the refrigerator up to 3 days.
Ladle soup into bowls, incorporating beans and vegetables in each and top with pesto and grated cheese, if desired. The soup can be refrigerated in an airtight container up to 3 days; thin with water, if necessary, before reheating over gentle heat.